def test_sharedconst1(self): # The const in this case is shared between Pad1 and Pad2 # separated by Abs which is not encapsulated. The Pad op # is different in the sense that the shared const is a # static input to it and is not used by the op directly # but is used to create 2 new Consts. openvino_tensorflow.set_disabled_ops('Abs') input_data1 = tf.compat.v1.placeholder(tf.float32, shape=(2, 3)) paddings = tf.compat.v1.constant([[2, 1], [2, 2]]) pad1 = tf.pad(input_data1, paddings) abs2 = tf.abs(pad1) pad2 = tf.pad(abs2, paddings) inp = ((4, 2, 4), (4, 4, 1)) pad = ((5, 3), (5, 5)) def run_test(sess): return sess.run(pad2, feed_dict={input_data1: inp}) if not (self.with_ngraph(run_test) == self.without_ngraph(run_test) ).all(): raise AssertionError # Clean up openvino_tensorflow.set_disabled_ops('')
def test_disable_op_2(self, invalid_op_list): # This test is disabled for grappler because grappler fails silently and # TF continues to run with the unoptimized graph # Note, tried setting fail_on_optimizer_errors, but grappler still failed silently # TODO: enable this test for grappler as well. if (not openvino_tensorflow.is_grappler_enabled()): openvino_tensorflow.set_disabled_ops(invalid_op_list) a = tf.compat.v1.placeholder(tf.int32, shape=(5,)) b = tf.constant(np.ones((5,)), dtype=tf.int32) c = a + b def run_test(sess): return sess.run(c, feed_dict={a: np.ones((5,))}) if not (self.without_ngraph(run_test) == np.ones(5,) * 2).all(): raise AssertionError #import pdb; pdb.set_trace() try: # This test is expected to fail, # since all the strings passed to set_disabled_ops have invalid ops in them res = self.with_ngraph(run_test) except: # Clean up openvino_tensorflow.set_disabled_ops('') return if not False: raise AssertionError('Had expected test to raise error')
def test_disable_op_1(self, op_list): openvino_tensorflow.set_disabled_ops(op_list) if not openvino_tensorflow.get_disabled_ops() == op_list.encode( "utf-8"): raise AssertionError # Running get_disabled_ops twice to see nothing has changed between 2 consecutive calls if not openvino_tensorflow.get_disabled_ops() == op_list.encode( "utf-8"): raise AssertionError # Clean up openvino_tensorflow.set_disabled_ops('')
def test_disable_op_env(self): op_list = 'Select,Where' openvino_tensorflow.set_disabled_ops(op_list) if not openvino_tensorflow.get_disabled_ops() == op_list.encode( "utf-8"): raise AssertionError env_map = self.store_env_variables('OPENVINO_TF_DISABLED_OPS') env_list = 'Squeeze' self.set_env_variable('OPENVINO_TF_DISABLED_OPS', env_list) if not openvino_tensorflow.get_disabled_ops() == env_list.encode( "utf-8"): raise AssertionError self.unset_env_variable('OPENVINO_TF_DISABLED_OPS') self.restore_env_variables(env_map) # Clean up openvino_tensorflow.set_disabled_ops('')