MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / XLA_TEST_F

Function XLA_TEST_F

tensorflow/compiler/xla/tests/while_test.cc:51–79  ·  view source on GitHub ↗

Tests a while node when the result type T is S32. int32 result = 0; while (result < 5) { result = result + 1; }

Source from the content-addressed store, hash-verified

49// result = result + 1;
50// }
51XLA_TEST_F(WhileTest, WhileWithScalarS32Result) {
52 auto result_shape = ShapeUtil::MakeShape(S32, {});
53
54 // Create a computation for the condition: repeat for 5 iterations.
55 XlaComputation condition;
56 {
57 XlaBuilder builder("condition");
58 auto prev = Parameter(&builder, 0, result_shape, "prev");
59 Gt(ConstantR0<int32>(&builder, 5), prev);
60 condition = builder.Build().ConsumeValueOrDie();
61 }
62
63 // Create a computation for the body: add 1 to the result variable.
64 XlaComputation body;
65 {
66 XlaBuilder builder("body");
67 auto prev = Parameter(&builder, 0, result_shape, "prev");
68 auto input = ConstantR0<int32>(&builder, 1);
69 Add(input, prev);
70 body = builder.Build().ConsumeValueOrDie();
71 }
72
73 // Create a While node with computations for the condition and the body.
74 XlaBuilder builder(TestName());
75 auto init = ConstantR0<int32>(&builder, 0);
76 While(condition, body, init);
77
78 ComputeAndCompareR0<int32>(&builder, 5, {});
79}
80
81// Tests a while node when the result type T is S64.
82//

Callers

nothing calls this directly

Calls 15

MakeShapeFunction · 0.85
TestNameFunction · 0.85
BroadcastFunction · 0.85
DynamicUpdateSliceFunction · 0.85
ConcatInDimFunction · 0.85
RngUniformFunction · 0.85
InfeedFunction · 0.85
ConsumeValueOrDieMethod · 0.80
set_seedMethod · 0.80
ErrorSpecClass · 0.70
ParameterFunction · 0.50

Tested by

no test coverage detected