abs function

VARP abs(
  1. VARP x
)

Computes the absolute value of a variable. Given a variable of integer or floating-point values, this operation returns a variable of the same type, where each element contains the absolute value of the corresponding element in the input.

x = MNN.const((-1.0, -2.0, 3.0), (3, ))
x = MNN.abs(x)  # (1.0, 2.0, 3.0)

Args:

  • x: A variable of type Halide_Type_Int or Halide_Type_Float

Returns:

  • A variable the same size, type as x with absolute values.

Implementation

VARP abs(VARP x) => VARP.fromPointer(C.mnn_expr_Abs(x.ptr));