aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler/xla/shape_util_test.cc
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2017-12-18 15:14:59 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-12-18 15:18:59 -0800
commit7fd2c7a7f8650a128213b19b13cb6ced65e87696 (patch)
tree5261f1d8b4f1d1184d2bcff97aa66a2e250a85e2 /tensorflow/compiler/xla/shape_util_test.cc
parent2daf4aa01b3d1d837eaaaebcbe4527b521cca7a9 (diff)
[XLA] Add format field to layout
Format will describe the method used to store array data in memory. Currently only DENSE is supported, which represents the way XLA currently stores arrays. Scalars have a DENSE format. Tuples and opaque shapes use INVALID_FORMAT. Adds checks to code that uses minor_to_major to ensure the layout is dense. PiperOrigin-RevId: 179475450
Diffstat (limited to 'tensorflow/compiler/xla/shape_util_test.cc')
-rw-r--r--tensorflow/compiler/xla/shape_util_test.cc32
1 files changed, 9 insertions, 23 deletions
diff --git a/tensorflow/compiler/xla/shape_util_test.cc b/tensorflow/compiler/xla/shape_util_test.cc
index 4bce7ca51d..3be6d6c429 100644
--- a/tensorflow/compiler/xla/shape_util_test.cc
+++ b/tensorflow/compiler/xla/shape_util_test.cc
@@ -165,20 +165,6 @@ TEST(ShapeUtilTest, IncompatibleTuplesWithDifferentDimensions) {
EXPECT_FALSE(ShapeUtil::Compatible(tuple1, tuple2));
}
-TEST(ShapeUtilTest, EmptyLayoutEqualsMissingLayout) {
- // A shape with a missing layout should be equal to a shape with an empty
- // layout.
- Shape scalar1 = ShapeUtil::MakeShape(F32, {});
- Shape scalar2 = ShapeUtil::MakeShape(F32, {});
-
- EXPECT_TRUE(ShapeUtil::Equal(scalar1, scalar2));
-
- scalar1.clear_layout(); // Remove layout field.
- scalar2.mutable_layout(); // Create empty layout field.
-
- EXPECT_TRUE(ShapeUtil::Equal(scalar1, scalar2));
-}
-
TEST(ShapeUtilTest, CompareShapesWithPaddedDimensionsMismatch) {
Shape shape1 = ShapeUtil::MakeShape(F32, {20, 30});
shape1.mutable_layout()->add_padded_dimensions(10);
@@ -199,17 +185,17 @@ TEST(ShapeUtilTest, CompareShapesWithPaddingValueMismatch) {
EXPECT_FALSE(ShapeUtil::Equal(shape1, shape2));
}
-TEST(ShapeUtilTest, ScalarUnpopulatedLayoutEqualsScalarLayout) {
- Shape scalar_unpopulated = ShapeUtil::MakeShape(F32, {});
- scalar_unpopulated.clear_layout();
- ASSERT_FALSE(scalar_unpopulated.has_layout())
- << ShapeUtil::HumanStringWithLayout(scalar_unpopulated);
+TEST(ShapeUtilTest, ScalarDefaultLayoutEqualsScalarEmptyMin2Maj) {
+ Shape scalar_default_layout = ShapeUtil::MakeShape(F32, {});
+ ASSERT_TRUE(scalar_default_layout.has_layout())
+ << ShapeUtil::HumanStringWithLayout(scalar_default_layout);
- const Shape scalar_populated = ShapeUtil::MakeShapeWithLayout(F32, {}, {});
- ASSERT_TRUE(scalar_populated.has_layout())
- << ShapeUtil::HumanStringWithLayout(scalar_populated);
+ const Shape scalar_empty_min2maj =
+ ShapeUtil::MakeShapeWithLayout(F32, {}, {});
+ ASSERT_TRUE(scalar_empty_min2maj.has_layout())
+ << ShapeUtil::HumanStringWithLayout(scalar_empty_min2maj);
- EXPECT_TRUE(ShapeUtil::Equal(scalar_unpopulated, scalar_populated));
+ EXPECT_TRUE(ShapeUtil::Equal(scalar_default_layout, scalar_empty_min2maj));
}
TEST(ShapeUtilTest, ByteSizeOfWithoutPadding) {