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

Function TEST_P

tensorflow/compiler/xla/tests/array_elementwise_ops_test.cc:321–359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

319}
320
321TEST_P(ArrayElementwiseOpTestParamCount, AddManyValues) {
322 const int count = GetParam();
323 XlaBuilder builder(TestName());
324 std::vector<float> a_values;
325 std::vector<float> b_values;
326 for (int i = 0; i < count; ++i) {
327 a_values.push_back(i / static_cast<float>(count));
328 b_values.push_back(2 * i / static_cast<float>(count + 2));
329 }
330
331 Literal a_literal = LiteralUtil::CreateR1<float>({a_values});
332 std::unique_ptr<GlobalData> a_data =
333 client_->TransferToServer(a_literal).ConsumeValueOrDie();
334 auto a_constant = ConstantR1<float>(&builder, a_values);
335 auto a_param = Parameter(&builder, 0, a_literal.shape(), "a_param");
336
337 Literal b_literal = LiteralUtil::CreateR1<float>({b_values});
338 std::unique_ptr<GlobalData> b_data =
339 client_->TransferToServer(b_literal).ConsumeValueOrDie();
340 auto b_param = Parameter(&builder, 1, a_literal.shape(), "b_param");
341 auto b_constant = ConstantR1<float>(&builder, b_values);
342
343 auto sum1 = Add(a_constant, b_param);
344 auto sum2 = Add(a_constant, b_constant);
345 auto sum3 = Add(a_param, b_param);
346 auto sum4 = Add(a_param, b_constant);
347
348 auto sum = Add(sum1, sum2);
349 sum = Add(sum, sum3);
350 sum = Add(sum, sum4);
351
352 std::vector<float> expected;
353 for (int64 i = 0; i < count; ++i) {
354 expected.push_back(4 * (a_values[i] + b_values[i]));
355 }
356
357 ComputeAndCompareR1<float>(&builder, expected, {a_data.get(), b_data.get()},
358 error_spec_);
359}
360
361XLA_TEST_F(ArrayElementwiseOpTest, DeeplyNestedAddWithSlices) {
362 XlaBuilder builder(TestName());

Callers

nothing calls this directly

Calls 12

GetParamFunction · 0.85
TestNameFunction · 0.85
ConsumeValueOrDieMethod · 0.80
ParameterFunction · 0.50
AddClass · 0.50
PowFunction · 0.50
push_backMethod · 0.45
TransferToServerMethod · 0.45
shapeMethod · 0.45
getMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected