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

Method ACOS>

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

Source from the content-addressed store, hash-verified

59//! ACOS: pi / 2 - arctan2(x, sqrt(1 - x * x))
60template <>
61mlir::Value lower_mode<Mode::ACOS>(
62 mlir::OpBuilder& builder, mlir::Location loc, ValueRange operands) {
63 ValueBuilderHelper helper(builder, loc);
64 auto x = operands[0];
65 auto one_minus_x_2 = helper.sub(helper.const_f32(1.f), helper.mul(x, x));
66 auto asin = atan2_approx(helper, x, helper.sqrt(one_minus_x_2));
67 auto pi_over_2 = helper.const_f32(1.57079637f);
68 return helper.sub(pi_over_2, asin);
69}
70
71//! ASIN: arctan2(x, sqrt(1 - x * x))
72template <>

Callers

nothing calls this directly

Calls 5

atan2_approxFunction · 0.85
const_f32Method · 0.80
mulMethod · 0.80
subMethod · 0.45
sqrtMethod · 0.45

Tested by

no test coverage detected