|
|
|
@ -17,6 +17,8 @@ from __future__ import print_function
|
|
|
|
import op_test
|
|
|
|
import op_test
|
|
|
|
import unittest
|
|
|
|
import unittest
|
|
|
|
import numpy
|
|
|
|
import numpy
|
|
|
|
|
|
|
|
import paddle.fluid as fluid
|
|
|
|
|
|
|
|
from paddle.fluid import Program, program_guard
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_test_class(op_type, typename, callback):
|
|
|
|
def create_test_class(op_type, typename, callback):
|
|
|
|
@ -45,5 +47,16 @@ for _type_name in {'float32', 'float64', 'int32', 'int64'}:
|
|
|
|
create_test_class('equal', _type_name, lambda _a, _b: _a == _b)
|
|
|
|
create_test_class('equal', _type_name, lambda _a, _b: _a == _b)
|
|
|
|
create_test_class('not_equal', _type_name, lambda _a, _b: _a != _b)
|
|
|
|
create_test_class('not_equal', _type_name, lambda _a, _b: _a != _b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestCompareOpError(op_test.OpTest):
|
|
|
|
|
|
|
|
def test_errors(self):
|
|
|
|
|
|
|
|
with program_guard(Program(), Program()):
|
|
|
|
|
|
|
|
# The input x and y of compare_op must be Variable.
|
|
|
|
|
|
|
|
x = fluid.layers.data(name='x', shape=[1], dtype="float32")
|
|
|
|
|
|
|
|
y = fluid.create_lod_tensor(
|
|
|
|
|
|
|
|
numpy.array([[-1]]), [[1]], fluid.CPUPlace())
|
|
|
|
|
|
|
|
self.assertRaises(TypeError, fluid.layers.greater_equal, x, y)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|
|
|
|
unittest.main()
|
|
|
|
|