コード例 #1
0
ファイル: shape_ops_test.py プロジェクト: BloodD/tensorflow
  def _test64BitOutput(self):
    with self.test_session():
      inp = tf.zeros([2**31])
      num_elements = array_ops.size_internal(
          inp, optimize=False, out_type=tf.int64)
      self.assertEqual(2**31, num_elements.eval())

    # Too large for tf.int32 output.
    with self.assertRaises(tf.errors.InvalidArgumentError):
      with self.test_session():
        inp = tf.zeros([2**31])
        num_elements = array_ops.size_internal(
            inp, optimize=False, out_type=tf.int32)
        self.assertEqual(2**31, num_elements.eval())
コード例 #2
0
  def _test64BitOutput(self):
    with self.cached_session():
      inp = array_ops.zeros([2**31])
      num_elements = array_ops.size_internal(
          inp, optimize=False, out_type=dtypes.int64)
      self.assertEqual(2**31, self.evaluate(num_elements))

    # Too large for tf.int32 output.
    with self.assertRaises(errors_impl.InvalidArgumentError):
      with self.cached_session():
        inp = array_ops.zeros([2**31])
        num_elements = array_ops.size_internal(
            inp, optimize=False, out_type=dtypes.int32)
        self.assertEqual(2**31, self.evaluate(num_elements))
コード例 #3
0
  def _test64BitOutput(self):
    with self.cached_session():
      inp = array_ops.zeros([2**31])
      num_elements = array_ops.size_internal(
          inp, optimize=False, out_type=dtypes.int64)
      self.assertEqual(2**31, self.evaluate(num_elements))

    # Too large for tf.int32 output.
    with self.assertRaises(errors_impl.InvalidArgumentError):
      with self.cached_session():
        inp = array_ops.zeros([2**31])
        num_elements = array_ops.size_internal(
            inp, optimize=False, out_type=dtypes.int32)
        self.assertEqual(2**31, self.evaluate(num_elements))
コード例 #4
0
    def _test64BitOutput(self):
        with self.test_session():
            inp = tf.zeros([2**31])
            num_elements = array_ops.size_internal(inp,
                                                   optimize=False,
                                                   out_type=tf.int64)
            self.assertEqual(2**31, num_elements.eval())

        # Too large for tf.int32 output.
        with self.assertRaises(tf.errors.InvalidArgumentError):
            with self.test_session():
                inp = tf.zeros([2**31])
                num_elements = array_ops.size_internal(inp,
                                                       optimize=False,
                                                       out_type=tf.int32)
                self.assertEqual(2**31, num_elements.eval())
コード例 #5
0
 def testSize(self):
   size_op = lambda x: array_ops.size_internal(x, optimize=False)
   for dtype in self.numeric_types:
     self._testUnary(size_op, dtype(7), expected=np.int32(1))
     self._testUnary(
         size_op, np.array([[], []], dtype=dtype), expected=np.int32(0))
     self._testUnary(
         size_op, np.array([-1, 1], dtype=dtype), expected=np.int32(2))
     self._testUnary(
         size_op, np.array([[-1, 1]], dtype=dtype), expected=np.int32(2))
     self._testUnary(
         size_op,
         np.array([[-1], [1], [4]], dtype=dtype),
         expected=np.int32(3))
コード例 #6
0
 def testSize(self):
   size_op = lambda x: array_ops.size_internal(x, optimize=False)
   for dtype in self.numeric_types:
     self._assertOpOutputMatchesExpected(
         size_op, dtype(7), expected=np.int32(1))
     self._assertOpOutputMatchesExpected(
         size_op, np.array([[], []], dtype=dtype), expected=np.int32(0))
     self._assertOpOutputMatchesExpected(
         size_op, np.array([-1, 1], dtype=dtype), expected=np.int32(2))
     self._assertOpOutputMatchesExpected(
         size_op, np.array([[-1, 1]], dtype=dtype), expected=np.int32(2))
     self._assertOpOutputMatchesExpected(
         size_op,
         np.array([[-1], [1], [4]], dtype=dtype),
         expected=np.int32(3))
コード例 #7
0
 def size_op(x):
   return array_ops.size_internal(x, optimize=False, out_type=np.int64)
コード例 #8
0
ファイル: unary_ops_test.py プロジェクト: jackd/tensorflow
 def size_op(x):
   return array_ops.size_internal(x, optimize=False, out_type=np.int64)