Removing run_deprecated_v1 and run_v1_only tags on tests for array_ops

PiperOrigin-RevId: 347267934
Change-Id: Id8d1edfa7ff51c1ba3d9fc496d51a981a19c2ba9
This commit is contained in:
A. Unique TensorFlower 2020-12-13 10:18:02 -08:00 committed by TensorFlower Gardener
parent 92f07a46bb
commit 3727302f03
3 changed files with 486 additions and 567 deletions

File diff suppressed because it is too large Load Diff

View File

@ -42,15 +42,3 @@ cuda_py_test(
"//tensorflow/python:session_ops",
],
)
cuda_py_test(
name = "array_ops_test",
size = "small",
srcs = ["array_ops_test.py"],
deps = [
"//tensorflow/python:array_ops",
"//tensorflow/python:framework",
"//tensorflow/python:framework_for_generated_wrappers",
"//tensorflow/python:framework_test_lib",
],
)

View File

@ -1,88 +0,0 @@
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Tests for array_ops that only work in V1."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import errors
from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import test_util
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import variables
from tensorflow.python.platform import test as test_lib
class ReverseV2Test(test_util.TensorFlowTestCase):
# Pure shape inference test only V1
@test_util.run_deprecated_v1
def testUnknownDims(self):
reverse_v2 = array_ops.reverse_v2
data_t = array_ops.placeholder(dtypes.float32)
axis_known_t = array_ops.placeholder(dtypes.int32, shape=[3])
reverse_known_t = reverse_v2(data_t, axis_known_t)
# Unlike V1 we cannot know this anymore
self.assertIsNone(reverse_known_t.get_shape().ndims)
axis_unknown_t = array_ops.placeholder(dtypes.int32)
reverse_unknown_t = reverse_v2(data_t, axis_unknown_t)
self.assertIs(None, reverse_unknown_t.get_shape().ndims)
data_2d_t = array_ops.placeholder(dtypes.float32, shape=[None, None])
axis_2d_t = array_ops.placeholder(dtypes.int32, shape=[3])
reverse_2d_t = reverse_v2(data_2d_t, axis_2d_t)
self.assertEqual(2, reverse_2d_t.get_shape().ndims)
class SequenceMaskTest(test_util.TensorFlowTestCase):
# Pure shape inference test only V1
@test_util.run_deprecated_v1
def testUnknownShape(self):
lengths = array_ops.placeholder(dtype=dtypes.int32)
res = array_ops.sequence_mask(lengths)
self.assertEqual(res.shape, None) # pylint: disable=g-generic-assert
class BatchGatherNdTest(test_util.TensorFlowTestCase):
# Pure shape inference test only V1
@test_util.run_deprecated_v1
def testUnknownIndices(self):
"""Tests whether indices with unknown rank works correctly."""
params = constant_op.constant(((0, 1, 2),))
indices = array_ops.placeholder(dtypes.int32)
gather_nd_t = array_ops.gather_nd(params, indices, batch_dims=1)
shape = gather_nd_t.get_shape()
self.assertIsNone(shape.ndims)
self.assertIsNone(tensor_shape.dimension_value(shape[0]))
class SliceAssignTest(test_util.TensorFlowTestCase):
@test_util.run_v1_only("Variables need initialization only in V1")
def testUninitialized(self):
with self.assertRaisesRegex(
errors.FailedPreconditionError,
"Attempting to use uninitialized value Variable"):
v = variables.VariableV1([1, 2])
self.evaluate(v[:].assign([1, 2]))
if __name__ == "__main__":
test_lib.main()