def testConcatNegativeAxis(self):
    with self.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 = self.evaluate(c)
      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 = self.evaluate(c)
      self.assertAllEqual([[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12]], output)
Beispiel #2
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)
 def testConcatEmpty(self):
     with test_util.use_gpu():
         t1 = []
         t2 = []
         output = gen_array_ops.concat_v2([t1, t2], 0)
         self.assertFalse(
             self.evaluate(output))  # Checks that output is empty
 def testConcatQint8GPU(self):
     with self.test_session(use_gpu=True):
         p1 = np.random.rand(2, 3, 2, 3, 4).astype("i")
         p2 = np.random.rand(2, 3, 2, 3, 4).astype("i")
         x1 = constant_op.constant(p1, dtypes.qint8)
         x2 = constant_op.constant(p2, dtypes.qint8)
         c = gen_array_ops.concat_v2([x1, x2], 1)
         result = self.evaluate(c)
     self.assertAllEqual(result[:, :3, :], p1)
     self.assertAllEqual(result[:, 3:, :], p2)
  def testConcatAxisType(self):
    for dtype in [dtypes.int32, dtypes.int64]:
      with self.cached_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],
                                    constant_op.constant(1, dtype=dtype))
        self.assertEqual([2, 6], c.get_shape().as_list())
        output = self.evaluate(c)
        self.assertAllEqual([[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12]], output)
Beispiel #6
0
  def testConcatAxisType(self):
    for dtype in [dtypes.int32, dtypes.int64]:
      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],
                                    constant_op.constant(1, dtype=dtype))
        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)
Beispiel #7
0
    def testConcatDtype(self):
        for dtype in [
                dtypes.int32, dtypes.int64, dtypes.uint32, dtypes.uint64
        ]:
            with test_util.use_gpu():
                t1 = constant_op.constant([[1, 2, 3], [4, 5, 6]], dtype=dtype)
                t2 = constant_op.constant([[7, 8, 9], [10, 11, 12]],
                                          dtype=dtype)

                c = gen_array_ops.concat_v2([t1, t2], 1)
                self.assertEqual([2, 6], c.get_shape().as_list())
                output = self.evaluate(c)
                self.assertAllEqual(
                    [[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12]], output)
 def testConcatInvalidAxis(self):
     with self.assertRaises(ValueError):
         with test_util.use_gpu():
             t1 = [1]
             t2 = [2]
             gen_array_ops.concat_v2([t1, t2], 1).eval()
 def testConcatInvalidAxis(self):
   with self.assertRaises(ValueError):
     with self.session(use_gpu=True):
       t1 = [1]
       t2 = [2]
       gen_array_ops.concat_v2([t1, t2], 1).eval()
 def testConcatEmpty(self):
   with self.session(use_gpu=True):
     t1 = []
     t2 = []
     output = gen_array_ops.concat_v2([t1, t2], 0).eval()
     self.assertFalse(output)  # Checks that output is empty
Beispiel #11
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()
Beispiel #12
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
Beispiel #13
0
 def concat_wrapper():
     y = gen_array_ops.concat_v2(values=[[1, 2, 3], [4, 5, 6]],
                                 axis=0xb500005b)
     return y
 def testConcatInvalidAxis(self):
   with self.assertRaises(ValueError):
     with test_util.use_gpu():
       t1 = [1]
       t2 = [2]
       gen_array_ops.concat_v2([t1, t2], 1).eval()
 def testConcatEmpty(self):
   with test_util.use_gpu():
     t1 = []
     t2 = []
     output = gen_array_ops.concat_v2([t1, t2], 0)
     self.assertFalse(self.evaluate(output))  # Checks that output is empty