Unary¶
Computes a unary operation for each element of the input tensor.
Attributes¶
operation Unary operation can be one of:
EXP\(output=e^{input}\)LOG\(output=log_e(input)\)SQRT\(output=\sqrt{input}\)RECIP\(output=\frac{1}{input}\)ABS\(output=|input|\)NEG\(output=-input\)SIN\(output=sin(input)\)COS\(output=cos(input)\)TAN\(output=tan(input)\)SINH\(output=sinh(input)\)COSH\(output=cosh(input)\)ASIN\(output=asin(input)\)ACOS\(output=acos(input)\)ATAN\(output=atan(input)\)ASINH\(output=asinh(input)\)ACOSH\(output=acosh(input)\)ATANH\(output=atanh(input)\)CEIL\(output=\lceil input \rceil\)FLOOR\(output=\lfloor input \rfloor\)ERF\(output=gef(input) \, \text{, gef is a Gaussian Error Function}\)NOT\(output=~input\)SIGN\(output=sign(input)\)ROUND\(output=round(input)\)ISINF\(output=isinf(input)\)ISNAN\(output=isnan(input)\)
Inputs¶
input: tensor of type T
Outputs¶
output: tensor of type T. ISINF and ISNAN only outputs bool type.
Data Types¶
Operation |
T |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Shape Information¶
The output has the same shape as the input.
Examples¶
Unary
in1 = network.add_input("input1", dtype=trt.float32, shape=(2, 3))
layer = network.add_unary(in1, op=trt.UnaryOperation.ABS)
network.mark_output(layer.get_output(0))
inputs[in1.name] = np.array([[-3.0, -2.0, -1.0], [0.0, 1.0, 2.0]])
outputs[layer.get_output(0).name] = layer.get_output(0).shape
expected[layer.get_output(0).name] = np.array([[3.0, 2.0, 1.0], [0.0, 1.0, 2.0]])
C++ API¶
For more information about the C++ IUnaryLayer operator, refer to the C++ IUnaryLayer documentation.
Python API¶
For more information about the Python IUnaryLayer operator, refer to the Python IUnaryLayer documentation.