示例#1
0
def _test_eq_float(test_case, shape, device):
    arr = np.random.randn(*shape)
    input = flow.Tensor(arr, dtype=flow.float32, device=flow.device(device))
    num = 1
    of_out = flow.eq(input, num)
    np_out = np.equal(arr, num)
    test_case.assertTrue(np.array_equal(of_out.numpy(), np_out))
示例#2
0
文件: test_eq.py 项目: mosout/oneflow
def _test_eq(test_case, shape, device):
    arr1 = np.random.randn(*shape)
    arr2 = np.random.randn(*shape)
    input = flow.Tensor(arr1, dtype=flow.float32, device=flow.device(device))
    other = flow.Tensor(arr2, dtype=flow.float32, device=flow.device(device))

    of_out = flow.eq(input, other)
    of_out2 = flow.equal(input, other)
    np_out = np.equal(arr1, arr2)
    test_case.assertTrue(np.array_equal(of_out.numpy(), np_out))
    test_case.assertTrue(np.array_equal(of_out2.numpy(), np_out))
示例#3
0
    def test_eq(test_case):
        arr1 = np.array([
            2,
            3,
            4,
            5,
        ])
        arr2 = np.array([2, 3, 4, 1])
        input = flow.Tensor(arr1, dtype=flow.float32)
        other = flow.Tensor(arr2, dtype=flow.float32)

        of_out = flow.eq(input, other)
        of_out2 = flow.equal(input, other)
        np_out = np.equal(arr1, arr2)
        test_case.assertTrue(np.array_equal(of_out.numpy(), np_out))
        test_case.assertTrue(np.array_equal(of_out2.numpy(), np_out))