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

Function initialize_rocrand

tensorflow/stream_executor/rocm/rocm_rng.cc:284–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

282} // namespace gpu
283
284void initialize_rocrand() {
285 auto rocRandAlreadyRegistered = PluginRegistry::Instance()->HasFactory(
286 rocm::kROCmPlatformId, PluginKind::kRng, gpu::kGpuRandPlugin);
287
288 if (!rocRandAlreadyRegistered) {
289 port::Status status =
290 PluginRegistry::Instance()->RegisterFactory<PluginRegistry::RngFactory>(
291 rocm::kROCmPlatformId, gpu::kGpuRandPlugin, "rocRAND",
292 [](internal::StreamExecutorInterface* parent) -> rng::RngSupport* {
293 gpu::GpuExecutor* rocm_executor =
294 dynamic_cast<gpu::GpuExecutor*>(parent);
295 if (rocm_executor == nullptr) {
296 LOG(ERROR)
297 << "Attempting to initialize an instance of the hipRAND "
298 << "support library with a non-ROCM StreamExecutor";
299 return nullptr;
300 }
301
302 gpu::GpuRng* rng = new gpu::GpuRng(rocm_executor);
303 if (!rng->Init()) {
304 // Note: Init() will log a more specific error.
305 delete rng;
306 return nullptr;
307 }
308 return rng;
309 });
310
311 if (!status.ok()) {
312 LOG(ERROR) << "Unable to register rocRAND factory: "
313 << status.error_message();
314 }
315
316 PluginRegistry::Instance()->SetDefaultFactory(
317 rocm::kROCmPlatformId, PluginKind::kRng, gpu::kGpuRandPlugin);
318 }
319}
320
321} // namespace stream_executor
322

Callers 1

rocm_rng.ccFile · 0.85

Calls 4

HasFactoryMethod · 0.80
SetDefaultFactoryMethod · 0.80
InitMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected