TensorFlow中的并行执行引擎——StreamExecutor框架 (2)

TensorFlow中的并行执行引擎——StreamExecutor框架

CudaPlatform和HostPlatform继承自公共父类Platform,如果有新的Platform出现,依然可以沿用这样的设计直接继承并给出实现。所有的Platform都通过MultiPlaftormManager调用RegsiterPlatform函数主动注册到系统中并做初始化,下面代码段是CudaPlaftorm的注册过程,注册使用了Initializer模块及相应的宏定义,这些代码比较简单,这里就不再详细展开了。

1 static void InitializeCudaPlatform() { 2 // Disabling leak checking, MultiPlatformManager does not destroy its 3 // registered platforms. 4 5 std::unique_ptr<cuda::CudaPlatform> platform(new cuda::CudaPlatform); 6 SE_CHECK_OK(MultiPlatformManager::RegisterPlatform(std::move(platform))); 7 } 8 9 } // namespace stream_executor 10 11 REGISTER_MODULE_INITIALIZER(cuda_platform, 12 stream_executor::InitializeCudaPlatform()); 13 14 // Note that module initialization sequencing is not supported in the 15 // open-source project, so this will be a no-op there. 16 REGISTER_MODULE_INITIALIZER_SEQUENCE(cuda_platform, multi_platform_manager); 17 REGISTER_MODULE_INITIALIZER_SEQUENCE(multi_platform_manager_listener, 18 cuda_platform);

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zywpfp.html