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

Function main

tensorflow/compiler/tests/randomized_tests.cc:3419–3468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3417} // namespace tensorflow
3418
3419int main(int argc, char** argv) {
3420 tensorflow::tf_xla_test_device_ptr = new tensorflow::string("GPU:0");
3421 tensorflow::tf_xla_reference_device_ptr = new tensorflow::string("CPU:0");
3422 std::vector<tensorflow::Flag> flag_list = {
3423 tensorflow::Flag(
3424 "tf_xla_random_seed", &tensorflow::tf_xla_random_seed,
3425 "Random seed to use for XLA tests. <= 0 means choose a seed "
3426 "nondetermistically."),
3427 // TODO(phawkins): it might make more sense to run each test up to a
3428 // configurable time bound.
3429 tensorflow::Flag("tf_xla_test_repetitions",
3430 &tensorflow::tf_xla_test_repetitions,
3431 "Number of repetitions for each test."),
3432 tensorflow::Flag("tf_xla_max_tensor_size",
3433 &tensorflow::tf_xla_max_tensor_size,
3434 "Maximum number of elements for random input tensors."),
3435 tensorflow::Flag("tf_xla_test_device", tensorflow::tf_xla_test_device_ptr,
3436 "Tensorflow device type to use for test"),
3437 tensorflow::Flag("tf_xla_reference_device",
3438 tensorflow::tf_xla_reference_device_ptr,
3439 "Tensorflow device type to use for reference"),
3440 tensorflow::Flag("tf_xla_test_use_jit", &tensorflow::tf_xla_test_use_jit,
3441 "Use JIT compilation for the operator under test"),
3442 };
3443 tensorflow::string usage = tensorflow::Flags::Usage(argv[0], flag_list);
3444 const bool parse_result = tensorflow::Flags::Parse(&argc, argv, flag_list);
3445 if (!parse_result) {
3446 LOG(ERROR) << "\n" << usage;
3447 return 2;
3448 }
3449 testing::InitGoogleTest(&argc, argv);
3450 if (argc > 1) {
3451 LOG(ERROR) << "Unknown argument " << argv[1] << "\n" << usage;
3452 return 2;
3453 }
3454 // XLA devices register kernels at construction time; create all known devices
3455 // to make sure the kernels are registered.
3456 std::vector<std::unique_ptr<tensorflow::Device>> devices;
3457 TF_CHECK_OK(tensorflow::DeviceFactory::AddDevices(
3458 tensorflow::SessionOptions(), "", &devices));
3459 tensorflow::DeviceMgr device_mgr(std::move(devices));
3460
3461 tensorflow::Device* ignored;
3462 TF_QCHECK_OK(
3463 device_mgr.LookupDevice(*tensorflow::tf_xla_test_device_ptr, &ignored))
3464 << "Unknown test device (" << *tensorflow::tf_xla_test_device_ptr
3465 << "). Did you build in the right configuration (e.g., is CUDA enabled)?";
3466
3467 return RUN_ALL_TESTS();
3468}

Callers

nothing calls this directly

Calls 5

UsageFunction · 0.85
ParseFunction · 0.85
LookupDeviceMethod · 0.80
FlagClass · 0.50
SessionOptionsClass · 0.50

Tested by

no test coverage detected