| 140 | //! H_SWISH: x * clip(x + 3, 0, 6) / 6 |
| 141 | template <> |
| 142 | mlir::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) |
| 156 | template <> |