MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / H_SWISH>

Method H_SWISH>

src/jit/impl/mlir/ir/each_mode.cpp:142–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140//! H_SWISH: x * clip(x + 3, 0, 6) / 6
141template <>
142mlir::Value lower_mode<Mode::H_SWISH>(
143 mlir::OpBuilder& builder, mlir::Location loc, ValueRange operands) {
144 ValueBuilderHelper helper(builder, loc);
145
146 auto const_3 = helper.const_f32(3.f);
147 auto const_0 = helper.const_f32(0.f);
148 auto const_6 = helper.const_f32(6.f);
149 auto tmp = helper.add(operands[0], const_3);
150 return helper.div(
151 helper.mul(operands[0], helper.min(helper.max(tmp, const_0), const_6)),
152 const_6);
153}
154
155//! LOG1P: log(1 + p)
156template <>

Callers

nothing calls this directly

Calls 5

const_f32Method · 0.80
mulMethod · 0.80
addMethod · 0.45
minMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected