@@ -682,6 +682,49 @@ def test_forward_pad():
682
682
_test_pad ((2 , 3 ), [[1 ,1 ], [2 ,2 ]], mode = "CONSTANT" )
683
683
_test_pad ((2 , 3 ), [[1 ,1 ], [2 ,2 ]], mode = "CONSTANT" , constant_values = 1.0 )
684
684
685
+ #######################################################################
686
+ # Logical operators
687
+ # --------------------
688
+ def test_logical_and ():
689
+ with tf .Graph ().as_default ():
690
+ in1 = tf .placeholder (tf .bool , shape = [1 , 4 , 4 , 3 ], name = 'in1' )
691
+ in2 = tf .placeholder (tf .bool , shape = [1 , 4 , 4 , 3 ], name = 'in2' )
692
+ out = tf .logical_and (in1 , in2 , name = 'out' )
693
+ in_data1 = np .random .choice (a = [False , True ],size = (1 , 4 , 4 , 3 )).astype ('bool' )
694
+ in_data2 = np .random .choice (a = [False , True ],size = (1 , 4 , 4 , 3 )).astype ('bool' )
695
+ compare_tf_with_tvm ([in_data1 , in_data2 ], ['in1:0' , 'in2:0' ], 'out:0' )
696
+
697
+ def test_logical_or ():
698
+ with tf .Graph ().as_default ():
699
+ in1 = tf .placeholder (tf .bool , shape = [1 , 4 , 4 , 3 ], name = 'in1' )
700
+ in2 = tf .placeholder (tf .bool , shape = [1 , 4 , 4 , 3 ], name = 'in2' )
701
+ out = tf .logical_or (in1 , in2 , name = 'out' )
702
+ in_data1 = np .random .choice (a = [False , True ],size = (1 , 4 , 4 , 3 )).astype ('bool' )
703
+ in_data2 = np .random .choice (a = [False , True ],size = (1 , 4 , 4 , 3 )).astype ('bool' )
704
+ compare_tf_with_tvm ([in_data1 , in_data2 ], ['in1:0' , 'in2:0' ], 'out:0' )
705
+
706
+ def test_logical_xor ():
707
+ with tf .Graph ().as_default ():
708
+ in1 = tf .placeholder (tf .bool , shape = [1 , 4 , 4 , 3 ], name = 'in1' )
709
+ in2 = tf .placeholder (tf .bool , shape = [1 , 4 , 4 , 3 ], name = 'in2' )
710
+ out = tf .logical_xor (in1 , in2 , name = 'out' )
711
+ in_data1 = np .random .choice (a = [False , True ],size = (1 , 4 , 4 , 3 )).astype ('bool' )
712
+ in_data2 = np .random .choice (a = [False , True ],size = (1 , 4 , 4 , 3 )).astype ('bool' )
713
+ compare_tf_with_tvm ([in_data1 , in_data2 ], ['in1:0' , 'in2:0' ], 'out:0' )
714
+
715
+ def test_logical_not ():
716
+ with tf .Graph ().as_default ():
717
+ in1 = tf .placeholder (tf .bool , shape = [1 , 4 , 4 , 3 ], name = 'in1' )
718
+ out = tf .logical_not (in1 , name = 'out' )
719
+ in_data1 = np .random .choice (a = [False , True ],size = (1 , 4 , 4 , 3 )).astype ('bool' )
720
+ compare_tf_with_tvm (in_data1 , 'in1:0' , 'out:0' )
721
+
722
+ def test_forward_logical ():
723
+ test_logical_and ()
724
+ test_logical_or ()
725
+ test_logical_xor ()
726
+ test_logical_not ()
727
+
685
728
686
729
#######################################################################
687
730
# Inception V3
@@ -1109,5 +1152,4 @@ def test_forward_rel_ops():
1109
1152
1110
1153
# Relational ops
1111
1154
test_forward_rel_ops ()
1112
-
1113
-
1155
+ test_forward_logical ()
0 commit comments