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

Function XLA_TEST_P

tensorflow/compiler/xla/tests/conditional_test.cc:192–219  ·  view source on GitHub ↗

Test branch computations that do not take any parameters.

Source from the content-addressed store, hash-verified

190
191// Test branch computations that do not take any parameters.
192XLA_TEST_P(CaseOpTest, Parameters0) {
193 int num_branches = GetParam();
194 for (int bi = -1; bi <= num_branches; ++bi) {
195 SCOPED_TRACE(bi);
196 XlaBuilder builder(TestName());
197 XlaOp branch_index;
198 auto branch_index_arg = CreateR0Parameter<int32>(bi, 0, "branch_index_arg",
199 &builder, &branch_index);
200 auto operand = Tuple(&builder, {});
201
202 std::vector<XlaOp> operands(num_branches, operand);
203 std::vector<XlaComputation> branches;
204 branches.reserve(num_branches);
205 std::vector<const XlaComputation*> branches_p(num_branches);
206 for (int i = 0; i < num_branches; ++i) {
207 branches.emplace_back(
208 CreateR0ConstantComputation(static_cast<float>(i) * 10));
209 branches_p[i] = &branches[i];
210 }
211 Conditional(branch_index, branches_p, operands);
212
213 float expected = 10 * static_cast<float>((bi < 0 || bi >= num_branches)
214 ? num_branches - 1
215 : bi);
216 ComputeAndCompareR0<float>(&builder, expected, {branch_index_arg.get()},
217 error_spec_);
218 }
219}
220
221// Test true and false computations that take in 1 parameter.
222XLA_TEST_F(ConditionalOpTest, Parameters1) {

Callers

nothing calls this directly

Calls 14

GetParamFunction · 0.85
TestNameFunction · 0.85
CreateSubBuilderMethod · 0.80
BuildAndNoteErrorMethod · 0.80
TupleFunction · 0.50
ConditionalFunction · 0.50
StrCatFunction · 0.50
AddClass · 0.50
ParameterFunction · 0.50
MulFunction · 0.50
GetTupleElementFunction · 0.50
reserveMethod · 0.45

Tested by

no test coverage detected