Exemple #1
0
def test_gelu_operator_with_array():
    runtime = get_runtime()

    data_value = np.array([[-5, 1], [-2, 3]], dtype=np.float32)

    model = ov.gelu(data_value, "erf")
    computation = runtime.computation(model)

    result = computation()
    expected = np.array([[-1.6391277e-06, 8.4134471e-01], [-4.5500278e-02, 2.9959502]], dtype=np.float32)
    assert np.allclose(result, expected, 1e-6, 1e-6)
Exemple #2
0
def test_gelu_tanh_operator_with_array():
    runtime = get_runtime()

    data_value = np.array([[-5, 1], [-2, 3]], dtype=np.float32)

    model = ov.gelu(data_value, "tanh")
    computation = runtime.computation(model)

    result = computation()
    expected = np.array([[0.0, 0.841192], [-0.04540223, 2.9963627]], dtype=np.float32)

    assert np.allclose(result, expected, 1e-6, 1e-6)
Exemple #3
0
def test_gelu_tanh_operator_with_parameters():
    runtime = get_runtime()

    data_value = np.array([[-5, 1], [-2, 3]], dtype=np.float32)

    data_shape = [2, 2]
    parameter_data = ov.parameter(data_shape, name="Data", dtype=np.float32)

    model = ov.gelu(parameter_data, "tanh")
    computation = runtime.computation(model, parameter_data)

    result = computation(data_value)
    expected = np.array([[0.0, 0.841192], [-0.04540223, 2.9963627]], dtype=np.float32)
    assert np.allclose(result, expected, 1e-6, 1e-6)
Exemple #4
0
def test_gelu_operator_with_parameters():
    runtime = get_runtime()

    data_value = np.array([[-5, 1], [-2, 3]], dtype=np.float32)

    data_shape = [2, 2]
    parameter_data = ov.parameter(data_shape, name="Data", dtype=np.float32)

    model = ov.gelu(parameter_data, "erf")
    computation = runtime.computation(model, parameter_data)

    result = computation(data_value)
    expected = np.array([[-1.6391277e-06, 8.4134471e-01], [-4.5500278e-02, 2.9959502]], dtype=np.float32)
    assert np.allclose(result, expected, 1e-6, 1e-6)