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

Method RunMultipleTimes

tensorflow/compiler/xla/tests/hlo_test_base.cc:376–452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

374}
375
376::testing::AssertionResult HloTestBase::RunMultipleTimes(
377 string_view hlo_string, bool run_hlo_passes,
378 std::vector<ExecutionProfile>* profiles, string backend_config,
379 bool assert_determinism) {
380 int n = profiles->size();
381 std::vector<std::vector<Literal*>> fake_argument_ptrs(n);
382 std::vector<std::vector<Literal>> fake_arguments(n);
383 std::vector<std::unique_ptr<Executable>> executables(n);
384
385 for (int i = 0; i < n; ++i) {
386 auto module_or_status = ParseAndReturnVerifiedModule(hlo_string);
387 if (!module_or_status.ok()) {
388 return ::testing::AssertionFailure()
389 << "Error while parsing HLO text format: "
390 << module_or_status.status().ToString();
391 }
392 std::unique_ptr<HloModule> module =
393 std::move(module_or_status.ValueOrDie());
394
395 fake_arguments[i] = MakeFakeArguments(module.get()).ConsumeValueOrDie();
396 absl::c_transform(
397 fake_arguments[i], std::back_inserter(fake_argument_ptrs[i]),
398 [](const Literal& literal) { return const_cast<Literal*>(&literal); });
399
400 if (profiles != nullptr) {
401 // We have to enable HLO profiling since otherwise currently the
402 // ExecutionProfile is not correct.
403 //
404 // TODO(b/119432044): Fix collection of the ExecutionProfile
405 // so that this is not necessary.
406 HloModuleConfig config = module->config();
407 DebugOptions debug_options = config.debug_options();
408 debug_options.set_xla_hlo_profile(true);
409 config.set_debug_options(debug_options);
410 module->set_config(config);
411 }
412
413 if (!backend_config.empty()) {
414 // Set backend configuration if it is given.
415 HloInstruction* instruction =
416 module->entry_computation()->root_instruction();
417 instruction->set_raw_backend_config_string(backend_config);
418 }
419
420 auto executable =
421 test_runner_.CreateExecutable(std::move(module), run_hlo_passes);
422 if (!executable.ok()) {
423 return ::testing::AssertionFailure()
424 << executable.status().error_message();
425 }
426 executables[i] = std::move(executable.ValueOrDie());
427 }
428
429 absl::optional<Literal> canonical_output;
430 for (int i = 0; i < n; ++i) {
431 StatusOr<Literal> output =
432 test_runner_.Execute(std::move(executables[i]), fake_argument_ptrs[i],
433 /*profile=*/&((*profiles)[i]));

Callers

nothing calls this directly

Calls 15

MakeFakeArgumentsFunction · 0.85
ConsumeValueOrDieMethod · 0.80
set_debug_optionsMethod · 0.80
set_configMethod · 0.80
root_instructionMethod · 0.80
entry_computationMethod · 0.80
CreateExecutableMethod · 0.80
sizeMethod · 0.45
okMethod · 0.45
ToStringMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected