Exemple #1
0
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 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)
Exemple #3
0
def test_discrete_type_info():
    data_shape = [6, 12, 10, 24]
    data_parameter = ng.parameter(data_shape, name="Data", dtype=np.float32)
    k = np.int32(3)
    axis = np.int32(1)
    n1 = ng.topk(data_parameter, k, axis, "max", "value")
    n2 = ng.topk(data_parameter, k, axis, "max", "value")
    n3 = ng.sin(0.2)

    assert n1.type_info.name == "TopK"
    assert n3.type_info.name == "Sin"
    assert n1.get_type_info().name == "TopK"
    assert n3.get_type_info().name == "Sin"
    assert n1.type_info.name == n2.type_info.name
    assert n1.type_info.version == n2.type_info.version
    assert n1.type_info.parent == n2.type_info.parent
    assert n1.get_type_info().name == n2.get_type_info().name
    assert n1.get_type_info().version == n2.get_type_info().version
    assert n1.get_type_info().parent == n2.get_type_info().parent
    assert n1.get_type_info().name != n3.get_type_info().name
    assert n1.get_type_info().name > n3.get_type_info().name
    assert n1.get_type_info().name >= n3.get_type_info().name
    assert n3.get_type_info().name < n1.get_type_info().name
    assert n3.get_type_info().name <= n1.get_type_info().name
Exemple #4
0
def Sin(onnx_node,
        ng_inputs):  # type: (NodeWrapper, List[NgraphNode]) -> NgraphNode
    """Apply f(x) = sin(x) to the input tensor elementwise."""
    return ng.sin(ng_inputs[0])