Skip to content

Commit

Permalink
Add unbounded dynamism test for InfeedOp.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 623569098
  • Loading branch information
ghpvnist authored and tensorflower-gardener committed Apr 10, 2024
1 parent 12ef3fe commit f810e02
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions third_party/xla/xla/client/xla_builder_test.cc
Expand Up @@ -2274,6 +2274,29 @@ TEST(XlaBuilderTest, UnboundedGetTupleElement) {
GmockMatch(m::Op().WithShapeEqualTo(&expected)));
}

TEST(XlaBuilderTest, UnboundedInfeed) {
XlaBuilder b(TestName());
TF_ASSERT_OK_AND_ASSIGN(const Shape shape, ParseShape("f32[?, 10]"));
TF_ASSERT_OK_AND_ASSIGN(const Shape expected, ParseShape("f32[?, 10]"));
Infeed(/*builder=*/&b, /*shape=*/shape, /*config=*/"");
TF_ASSERT_OK_AND_ASSIGN(const std::unique_ptr<xla::HloModule> module,
BuildHloModule(b));
EXPECT_THAT(GetRoot(*module),
GmockMatch(m::Op().WithShapeEqualTo(&expected)));
}

TEST(XlaBuilderTest, UnboundedInfeedWithToken) {
XlaBuilder b(TestName());
TF_ASSERT_OK_AND_ASSIGN(const Shape shape, ParseShape("f32[?, 10]"));
TF_ASSERT_OK_AND_ASSIGN(const Shape expected,
ParseShape("(f32[?, 10], token[])"));
InfeedWithToken(/*token=*/CreateToken(&b), /*shape=*/shape, /*config=*/"");
TF_ASSERT_OK_AND_ASSIGN(const std::unique_ptr<xla::HloModule> module,
BuildHloModule(b));
EXPECT_THAT(GetRoot(*module),
GmockMatch(m::Op().WithShapeEqualTo(&expected)));
}

TEST(XlaBuilderTest, UnboundedMap) {
XlaBuilder b(TestName());
TF_ASSERT_OK_AND_ASSIGN(const Shape operand0, ParseShape("f32[2, ?, ?]"));
Expand Down

0 comments on commit f810e02

Please sign in to comment.