| 347 | } |
| 348 | |
| 349 | port::Status GpuExecutor::LoadModule(const MultiModuleLoaderSpec& spec, |
| 350 | ModuleHandle* module_handle) { |
| 351 | // In GpuExecutor we store the pointer to the GPU binary (PTX or CUBIN) as |
| 352 | // ModuleHandle::id(). |
| 353 | CUmodule cu_module; |
| 354 | if (spec.has_cuda_cubin_in_memory()) { |
| 355 | absl::MutexLock lock{&in_memory_modules_mu_}; |
| 356 | TF_RETURN_IF_ERROR(LoadModuleFromCuBin( |
| 357 | reinterpret_cast<const char*>(spec.cuda_cubin_in_memory().data()), |
| 358 | &cu_module)); |
| 359 | *module_handle = ModuleHandle(const_cast<void *>( |
| 360 | static_cast<const void *>(spec.cuda_cubin_in_memory().data()))); |
| 361 | return port::Status::OK(); |
| 362 | } else if (spec.has_cuda_ptx_in_memory()) { |
| 363 | if (cc_major_ == 0 && cc_minor_ == 0) { |
| 364 | return port::InternalError("Compute capability not set"); |
| 365 | } |
| 366 | |
| 367 | if (!spec.cuda_ptx_in_memory()) { |
| 368 | return port::InternalError("PTX not found in spec"); |
| 369 | } |
| 370 | |
| 371 | absl::MutexLock lock{&in_memory_modules_mu_}; |
| 372 | TF_RETURN_IF_ERROR( |
| 373 | LoadModuleFromPtx(spec.cuda_ptx_in_memory(), &cu_module)); |
| 374 | *module_handle = ModuleHandle(const_cast<void *>( |
| 375 | static_cast<const void *>(spec.cuda_ptx_in_memory()))); |
| 376 | return port::Status::OK(); |
| 377 | } |
| 378 | return port::InternalError("No method of loading CUDA module provided"); |
| 379 | } |
| 380 | |
| 381 | bool GpuExecutor::UnloadModule(ModuleHandle module_handle) { |
| 382 | const char *gpu_binary = reinterpret_cast<const char *>(module_handle.id()); |
nothing calls this directly
no test coverage detected