def test_pad(test_case): arg_dict = OrderedDict() arg_dict["device_type"] = ["cpu", "gpu"] arg_dict["flow_op"] = [flow.pad] arg_dict["tf_op"] = [tf.pad] arg_dict["input_shape"] = [(2, 2, 1, 3), (1, 1, 2, 3)] arg_dict["op_args"] = [ Args( [([1, 2], [0, 0], [1, 2], [1, 1])], tf.constant([([1, 2], [0, 0], [1, 2], [1, 1])]), ), Args( [([0, 0], [30, 0], [0, 1], [1, 0]), 99999999999999999999999999999999], [ tf.constant(([0, 0], [30, 0], [0, 1], [1, 0])), "constant", 99999999999999999999999999999999, ], ), Args( [([10, 0], [0, 0], [10, 20], [0, 0])], tf.constant([([10, 0], [0, 0], [10, 20], [0, 0])]), ), ] for arg in GenArgDict(arg_dict): CompareOpWithTensorFlow(**arg)
def test_sqrt(test_case): arg_dict = OrderedDict() arg_dict["device_type"] = ["gpu"] arg_dict["flow_op"] = [flow.math.sqrt] arg_dict["tf_op"] = [tf.math.sqrt] arg_dict["input_shape"] = [(10, 20, 30)] arg_dict["input_minval"] = [0] arg_dict["input_maxval"] = [100] for arg in GenArgDict(arg_dict): CompareOpWithTensorFlow(**arg)
def test_reshape(test_case): arg_dict = OrderedDict() arg_dict["device_type"] = ["gpu"] arg_dict["flow_op"] = [flow.reshape] arg_dict["tf_op"] = [tf.reshape] arg_dict["input_shape"] = [(10, 10, 10)] arg_dict["op_args"] = [ Args([(100, 10)]), Args([(10, 100)]), Args([(5, 20, 10)]), ] for arg in GenArgDict(arg_dict): CompareOpWithTensorFlow(**arg)
def test_scalar_add(test_case): arg_dict = OrderedDict() arg_dict["device_type"] = ["gpu", "cpu"] arg_dict["flow_op"] = [flow.math.add] arg_dict["tf_op"] = [tf.math.add] arg_dict["input_shape"] = [(10, 10, 10)] arg_dict["op_args"] = [ Args([1]), Args([-1]), Args([84223.19348]), Args([-3284.139]), ] for arg in GenArgDict(arg_dict): CompareOpWithTensorFlow(**arg)
def test_pad_5d(test_case): arg_dict = OrderedDict() arg_dict["device_type"] = ["cpu", "gpu"] arg_dict["flow_op"] = [flow.pad] arg_dict["tf_op"] = [tf.pad] arg_dict["input_shape"] = [(2, 2, 1, 3, 1), (1, 1, 2, 3, 1)] arg_dict["op_args"] = [ Args( [([1, 2], [3, 4], [5, 6], [7, 8], [9, 10])], tf.constant([([1, 2], [3, 4], [5, 6], [7, 8], [9, 10])]), ), Args( [([1, 1], [2, 2], [3, 3], [4, 4], [5, 5])], tf.constant([([1, 1], [2, 2], [3, 3], [4, 4], [5, 5])]), ), Args( [([0, 0], [0, 0], [10, 20], [0, 0], [3, 2])], tf.constant([([0, 0], [0, 0], [10, 20], [0, 0], [3, 2])]), ), ] for arg in GenArgDict(arg_dict): CompareOpWithTensorFlow(**arg)