def unary_op(op_str, a): if op_str == "Abs": return ng.abs(a) elif op_str == "Acos": return ng.acos(a) elif op_str == "Asin": return ng.asin(a) elif op_str == "Atan": return ng.atan(a) elif op_str == "Ceiling": return ng.ceiling(a) elif op_str == "Cos": return ng.cos(a) elif op_str == "Cosh": return ng.cosh(a) elif op_str == "Floor": return ng.floor(a) elif op_str == "log": return ng.log(a) elif op_str == "exp": return ng.exp(a) elif op_str == "negative": return ng.negative(a) elif op_str == "Sign": return ng.sign(a) elif op_str == "Sin": return ng.sin(a) elif op_str == "Sinh": return ng.sinh(a) elif op_str == "Sqrt": return ng.sqrt(a) elif op_str == "Tan": return ng.tan(a) elif op_str == "Tanh": return ng.tanh(a)
def Softsign(onnx_node, ng_inputs): # type: (NodeWrapper, List[NgraphNode]) -> NgraphNode """Apply Softsign function, f(x) = x / (1 + |x|) to the input tensor element-wise. :param onnx_node: The ONNX node representing this operation. :param ng_inputs: The input tensors. :return: The tensor with applied Softsign operation. """ return ng_inputs[0] / (1 + ng.abs(ng_inputs[0]))
def ReduceL1(onnx_node, ng_inputs): # type: (NodeWrapper, List[NgraphNode]) -> NgraphNode """Compute the L1 norm of the input tensor's element along the provided axes. :param onnx_node: The ONNX node representing this operation. :param ng_inputs: The input tensors. :return: The tensor with applied ReduceL1 operation. """ abs_node = ng.abs(ng_inputs[0]) return make_reduction_op(ng.sum, onnx_node, abs_node)
def unary_op(op_str, a): if op_str == 'Abs': return ng.abs(a) elif op_str == 'Acos': return ng.acos(a) elif op_str == 'Asin': return ng.asin(a) elif op_str == 'Atan': return ng.atan(a) elif op_str == 'Ceiling': return ng.ceiling(a) elif op_str == 'Cos': return ng.cos(a) elif op_str == 'Cosh': return ng.cosh(a) elif op_str == 'Floor': return ng.floor(a) elif op_str == 'log': return ng.log(a) elif op_str == 'exp': return ng.exp(a) elif op_str == 'negative': return ng.negative(a) elif op_str == 'Reverse': return ng.reverse(a, np.array([1]), 'index') elif op_str == 'Sign': return ng.sign(a) elif op_str == 'Sin': return ng.sin(a) elif op_str == 'Sinh': return ng.sinh(a) elif op_str == 'Sqrt': return ng.sqrt(a) elif op_str == 'Tan': return ng.tan(a) elif op_str == 'Tanh': return ng.tanh(a)