Esempio n. 1
0
def _test_concat_v2(data, dim):
    """ One iteration of ConcatV2 """

    with tf.Graph().as_default():
        gen_array_ops._concat_v2(data, dim)

        compare_tf_with_tvm(data, ['ConcatV2/values_0:0', 'ConcatV2/values_1:0'],
                            'ConcatV2:0')
Esempio n. 2
0
def _test_concat_v2(data, dim):
    """ One iteration of ConcatV2 """

    with tf.Graph().as_default():
        gen_array_ops._concat_v2(data, dim)

        compare_tf_with_tvm(data, ['ConcatV2/values_0:0', 'ConcatV2/values_1:0'],
                            'ConcatV2:0')
Esempio n. 3
0
 def testConcatV2NegativeAxis(self):
     with self.test_session(use_gpu=True):
         t1 = [[1, 2, 3], [4, 5, 6]]
         t2 = [[7, 8, 9], [10, 11, 12]]
         output = gen_array_ops._concat_v2([t1, t2], -2).eval()
         self.assertAllEqual(
             [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]], output)
         output = gen_array_ops._concat_v2([t1, t2], -1).eval()
         self.assertAllEqual([[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12]],
                             output)
Esempio n. 4
0
 def testConcatV2NegativeAxis(self):
   with self.test_session(use_gpu=True):
     t1 = [[1, 2, 3], [4, 5, 6]]
     t2 = [[7, 8, 9], [10, 11, 12]]
     output = gen_array_ops._concat_v2([t1, t2], -2).eval()
     self.assertAllEqual(
         [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],
         output)
     output = gen_array_ops._concat_v2([t1, t2], -1).eval()
     self.assertAllEqual(
         [[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12]],
         output)
Esempio n. 5
0
  def testConcatNegativeAxis(self):
    with self.test_session(use_gpu=True):
      t1 = [[1, 2, 3], [4, 5, 6]]
      t2 = [[7, 8, 9], [10, 11, 12]]

      c = gen_array_ops._concat_v2([t1, t2], -2)
      self.assertEqual([4, 3], c.get_shape().as_list())
      output = c.eval()
      self.assertAllEqual([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],
                          output)

      c = gen_array_ops._concat_v2([t1, t2], -1)
      self.assertEqual([2, 6], c.get_shape().as_list())
      output = c.eval()
      self.assertAllEqual([[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12]], output)
Esempio n. 6
0
    def testConcatNegativeAxis(self):
        with self.test_session(use_gpu=True):
            t1 = [[1, 2, 3], [4, 5, 6]]
            t2 = [[7, 8, 9], [10, 11, 12]]

            c = gen_array_ops._concat_v2([t1, t2], -2)
            self.assertEqual([4, 3], c.get_shape().as_list())
            output = c.eval()
            self.assertAllEqual(
                [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]], output)

            c = gen_array_ops._concat_v2([t1, t2], -1)
            self.assertEqual([2, 6], c.get_shape().as_list())
            output = c.eval()
            self.assertAllEqual([[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12]],
                                output)
Esempio n. 7
0
def _test_concat_v2(data, dim):
    """ One iteration of ConcatV2 """

    with tf.Graph().as_default():

        # pylint: disable=unused-variable
        concat_out = gen_array_ops._concat_v2(data, dim)
        # pylint: enable=unused-variable

        with tf.Session() as sess:
            graph_def = tf.graph_util.convert_variables_to_constants(
                sess,
                sess.graph.as_graph_def(add_shapes=True),
                ['ConcatV2'],
            )

            tf_output = run_tf_graph(
                sess, data, ['ConcatV2/values_0:0', 'ConcatV2/values_1:0'],
                'ConcatV2:0')
            tvm_output = run_tvm_graph(
                graph_def, data, ["ConcatV2/values_0", 'ConcatV2/values_1'],
                tf_output.shape, tf_output.dtype)

            np.testing.assert_allclose(tf_output, tvm_output)

            sess.close()
Esempio n. 8
0
 def testConcatInvalidAxis(self):
     with self.assertRaises(ValueError):
         with self.test_session(use_gpu=True):
             t1 = [1]
             t2 = [2]
             gen_array_ops._concat_v2([t1, t2], 1).eval()
Esempio n. 9
0
 def testConcatEmpty(self):
     with self.test_session(use_gpu=True):
         t1 = []
         t2 = []
         output = gen_array_ops._concat_v2([t1, t2], 0).eval()
         self.assertFalse(output)  # Checks that output is empty
Esempio n. 10
0
 def testConcatV2InvalidAxis(self):
   with self.assertRaises(ValueError):
     with self.test_session(use_gpu=True):
       t1 = [1]
       t2 = [2]
       gen_array_ops._concat_v2([t1, t2], 1).eval()
Esempio n. 11
0
 def testConcatV2Empty(self):
   with self.test_session(use_gpu=True):
     t1 = []
     t2 = []
     output = gen_array_ops._concat_v2([t1, t2], 0).eval()
     self.assertFalse(output)  # Checks that output is empty
Esempio n. 12
0
def _call_concat(values, axis, use_concat_v2):
  if use_concat_v2:
    return gen_array_ops._concat_v2(values, axis)
  else:
    return tf.concat(axis, values)
Esempio n. 13
0
def _call_concat(values, axis, use_concat_v2):
    if use_concat_v2:
        return gen_array_ops._concat_v2(values, axis)
    else:
        return tf.concat(axis, values)