From 44cad80a8953387161e080027314c23e36f99b5a Mon Sep 17 00:00:00 2001 From: qijun Date: Mon, 25 Dec 2017 11:41:30 +0800 Subject: [PATCH 1/3] update docs --- doc/design/support_new_device.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/design/support_new_device.md b/doc/design/support_new_device.md index fd23dc211a35fd..8bf5c16c3fffd8 100644 --- a/doc/design/support_new_device.md +++ b/doc/design/support_new_device.md @@ -25,13 +25,14 @@ There are mainly three parts that we have to consider while integrating a new de ### Place and DeviceContext +Please remind that device and computing library are not one-to-one corresponding. A device can have a lot of computing libraries and a computing library can also support several devices. #### Place -Fluid uses class [Place](https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/platform/place.h#L55) to represent different devices and computing libraries. There are inheritance relationships between different kinds of `Place`. +Fluid uses class [Place](https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/platform/place.h#L55) to represent the device memory where data is locating. If we add another device, we have to add corresponding `DevicePlace`. ``` - | CPUPlace --> MKLDNNPlace -Place --| CUDAPlace --> CUDNNPlace + | CPUPlace +Place --| CUDAPlace | FPGAPlace ``` @@ -43,7 +44,7 @@ typedef boost::variant Place; #### DeviceContext -Fluid uses class [DeviceContext](https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/platform/device_context.h#L30) to manage the resources in different hardwares, such as CUDA stream in `CDUADeviceContext`. There are also inheritance relationships between different kinds of `DeviceContext`. +Fluid uses class [DeviceContext](https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/platform/device_context.h#L30) to manage the resources in different libraries, such as CUDA stream in `CDUADeviceContext`. There are also inheritance relationships between different kinds of `DeviceContext`. ``` @@ -106,7 +107,7 @@ template size_t Used(Place place); ``` -To implementing these interfaces, we have to implement MemoryAllocator for different Devices +To implementing these interfaces, we have to implement MemoryAllocator for different Devices. #### Tensor @@ -243,6 +244,7 @@ REGISTER_OP_CUDA_KERNEL( Generally, we will impelement OpKernel for all Device/Library of an Operator. We can easily train a Convolutional Neural Network in GPU. However, some OpKernel is not sutibale on a specific Device. For example, crf operator can only run on CPU, whereas most other operators can run at GPU. To achieve high performance in such circumstance, we have to switch between different Device/Library. -We will discuss how to implement an efficient OpKernel switch policy. +For more details, please refer to following docs: -- TBD +- operator kernel type [doc](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/design/operator_kernel_type.md) +- switch kernel [doc](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/design/switch_kernel.md) From c882e35d7c4c9bfc8c31dcb6381a1349c31898ac Mon Sep 17 00:00:00 2001 From: qijun Date: Mon, 25 Dec 2017 11:54:10 +0800 Subject: [PATCH 2/3] follow comments --- doc/design/support_new_device.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/design/support_new_device.md b/doc/design/support_new_device.md index 8bf5c16c3fffd8..38eee1940aeecf 100644 --- a/doc/design/support_new_device.md +++ b/doc/design/support_new_device.md @@ -28,7 +28,7 @@ There are mainly three parts that we have to consider while integrating a new de Please remind that device and computing library are not one-to-one corresponding. A device can have a lot of computing libraries and a computing library can also support several devices. #### Place -Fluid uses class [Place](https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/platform/place.h#L55) to represent the device memory where data is locating. If we add another device, we have to add corresponding `DevicePlace`. +Fluid uses class [Place](https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/platform/place.h#L55) to represent the device memory where data is located. If we add another device, we have to add corresponding `DevicePlace`. ``` | CPUPlace From 15db7ad8018871362ca76edb59caaac4904e2960 Mon Sep 17 00:00:00 2001 From: qijun Date: Mon, 25 Dec 2017 14:14:49 +0800 Subject: [PATCH 3/3] fix typo --- doc/design/support_new_device.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/design/support_new_device.md b/doc/design/support_new_device.md index 38eee1940aeecf..f54b2b3694cc2a 100644 --- a/doc/design/support_new_device.md +++ b/doc/design/support_new_device.md @@ -107,7 +107,7 @@ template size_t Used(Place place); ``` -To implementing these interfaces, we have to implement MemoryAllocator for different Devices. +To implement these interfaces, we have to implement MemoryAllocator for different Devices. #### Tensor