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

Method CreateDevices

tensorflow/compiler/jit/xla_interpreter_device.cc:48–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48Status XlaInterpreterDeviceFactory::CreateDevices(
49 const SessionOptions& session_options, const string& name_prefix,
50 std::vector<std::unique_ptr<Device>>* devices) {
51 static XlaDeviceOpRegistrations* registrations = RegisterXlaDeviceKernels(
52 DEVICE_XLA_INTERPRETER, DEVICE_INTERPRETER_XLA_JIT);
53 (void)registrations;
54
55 XlaOpRegistry::DeviceRegistration registration;
56 registration.compilation_device_name = DEVICE_INTERPRETER_XLA_JIT;
57 registration.autoclustering_policy =
58 XlaOpRegistry::AutoclusteringPolicy::kAlways;
59 registration.cluster_resource_variable_ops_unsafely = true;
60 registration.cluster_stack_ops = false;
61 registration.cluster_tensor_array_ops = true;
62 registration.cluster_stateful_rng_ops = true;
63 registration.cluster_control_trigger = true;
64 registration.elide_assert_and_checknumerics = true;
65 registration.cluster_variant_ops = true;
66 registration.cluster_slow_ops = true;
67 registration.cluster_inaccurate_ops = true;
68 XlaOpRegistry::RegisterCompilationDevice(DEVICE_XLA_INTERPRETER,
69 registration);
70
71 TF_ASSIGN_OR_RETURN(
72 auto platform, se::MultiPlatformManager::PlatformWithName("Interpreter"));
73
74 XlaDevice::Options options;
75 options.platform = platform;
76 options.device_name_prefix = name_prefix;
77 options.device_name = DEVICE_XLA_INTERPRETER;
78 options.device_ordinal = 0;
79 options.compilation_device_name = DEVICE_INTERPRETER_XLA_JIT;
80 options.use_multiple_streams = false;
81 devices->push_back(absl::make_unique<XlaDevice>(session_options, options));
82
83 return Status::OK();
84}
85
86// Set priority to be below the default priority (50), so that Interpreter is
87// not selected as a high priority device over other default devices. See
88// constructor comments for Registrar in
89// tensorflow/core/common_runtime/device_factory.h for a list of priority for
90// devices.
91REGISTER_LOCAL_DEVICE_FACTORY(DEVICE_XLA_INTERPRETER,
92 XlaInterpreterDeviceFactory, 40);
93
94// Kernel registrations
95static bool OpFilter(KernelDef* kdef) { return true; }
96
97REGISTER_XLA_LAUNCH_KERNEL(DEVICE_XLA_INTERPRETER, XlaLocalLaunchOp,
98 kExecAllTypes);
99REGISTER_XLA_COMPILE_KERNEL(DEVICE_XLA_INTERPRETER, XlaCompileOp,
100 kExecAllTypes);
101REGISTER_XLA_RUN_KERNEL(DEVICE_XLA_INTERPRETER, XlaRunOp, kExecAllTypes);
102
103REGISTER_XLA_DEVICE_KERNELS(DEVICE_XLA_INTERPRETER, kExecAllTypes);
104REGISTER_XLA_BACKEND(DEVICE_INTERPRETER_XLA_JIT, kExecAllTypes, OpFilter);
105

Callers

nothing calls this directly

Calls 2

RegisterXlaDeviceKernelsFunction · 0.85
push_backMethod · 0.45

Tested by

no test coverage detected