From 1f91c7ce05c945617caca77d7e1e69c4277a22b6 Mon Sep 17 00:00:00 2001 From: tink2123 Date: Fri, 12 Oct 2018 16:06:19 +0800 Subject: [PATCH] fix doc typo for release/1.0.0 --- .../advanced_usage/deploy/anakin_tutorial.md | 73 +++++++++---------- .../development/gpu_profiling_cn.rst | 5 +- .../howto/inference/native_infer.md | 36 ++++----- .../howto/inference/paddle_tensorrt_infer.md | 4 +- 4 files changed, 56 insertions(+), 62 deletions(-) diff --git a/doc/fluid/advanced_usage/deploy/anakin_tutorial.md b/doc/fluid/advanced_usage/deploy/anakin_tutorial.md index 1658aae638774..befc969d99e23 100644 --- a/doc/fluid/advanced_usage/deploy/anakin_tutorial.md +++ b/doc/fluid/advanced_usage/deploy/anakin_tutorial.md @@ -114,67 +114,64 @@ Anakin中数据类型与基本数据类型的对应如下: 理论上,Anakin支持申明1维以上的tensor,但是对于Anakin中的Op来说,只支持NW、NHW、NCHW、NCHW_C4这四种LayOut,其中NCHW是默认的LayOuteType,NCHW_C4是专门针对于int8这种数据类型的。 - 例子 + **例子:** - 下面的代码将展示如何使用tensor, 我们建议先看看这些示例。 +下面的代码将展示如何使用tensor, 我们建议先看看这些示例。 - 要想获得更多关于tensor的信息, 请参考 *soure_path/core/tensor.h* +要想获得更多关于tensor的信息, 请参考 *soure_path/core/tensor.h* - > 1. 使用shape对象初始化tensor +1. 使用shape对象初始化tensor - ```c++ - //create a null tensor. A null tensor holds for nothing. - //tensor's buffer is resident at CPU and its datatype is AK_FLOAT. - //tensor's Layout is NCHW(default) - Tensor mytensor; + ```cpp + //create a null tensor. A null tensor holds for nothing. + //tensor's buffer is resident at CPU and its datatype is AK_FLOAT. + //tensor's Layout is NCHW(default) + Tensor mytensor; - //1. using shape object to create a tensor. - Shape shape1(NUM); //1-D shape. NUM is the number of dimention. - Tensor mytensor1(shape1); //1-D tensor. + //1. using shape object to create a tensor. + Shape shape1(NUM); //1-D shape. NUM is the number of dimention. + Tensor mytensor1(shape1); //1-D tensor. - // A 4-D shape - Shape shape2(N, C, H, W); // batch x channel x height x width + // A 4-D shape + Shape shape2(N, C, H, W); // batch x channel x height x width ``` - >`注意:Shape的维度必须和tensor的`[LayoutType](#layout)`相同,比如Shape(N,C,H,W), 那么Tensor的 LayoutType必须是NCHW,否则会出错。如下列代码所示` + `注意:Shape的维度必须和tensor的`[LayoutType](#layout)`相同,比如Shape(N,C,H,W), 那么Tensor的 LayoutType必须是NCHW,否则会出错。如下列代码所示` ```c++ - // A 4-D tensor. - Tensor mytensor2(shape2); //right - - //A 4-D tensor which is resident at GPU and its datatype is AK_INT8 - Tensor mytensor3(shape2); //right + // A 4-D tensor. + Tensor mytensor2(shape2); //right - Tensor mytensor4(shape2); //wrong!! shape's dimetion must be equal to tensor's Layout. - Tensor mytensor5(shape2); //wrong!!!! + //A 4-D tensor which is resident at GPU and its datatype is AK_INT8 + Tensor mytensor3(shape2); //right + Tensor mytensor4(shape2); //wrong!! shape's dimetion must be equal to tensor's Layout. + Tensor mytensor5(shape2); //wrong!!!! ``` - > 2. 使用现有的数据和shape初始化tensor +2. 使用现有的数据和shape初始化tensor ```c++ + /** + * A construtor of Tensor. + * data_ptr is a pointer to any data type of data + * TargetType is type of a platform [Anakin TargetType] + * id : device id + * shape: a Anakin shape + */ + Tensor(Dtype* data_ptr, TargetType_t target, int id, Shape shape); - /** - * A construtor of Tensor. - * data_ptr is a pointer to any data type of data - * TargetType is type of a platform [Anakin TargetType] - * id : device id - * shape: a Anakin shape - */ - Tensor(Dtype* data_ptr, TargetType_t target, int id, Shape shape); - - //using existing data feed to a tensor - Tensor mytensor(data_ptr, TargetType, device_id, shape); //shape must has dimention (N, C, H, W). - + //using existing data feed to a tensor + Tensor mytensor(data_ptr, TargetType, device_id, shape); //shape must has dimention (N, C, H, W). ``` - > 3. 使用tensor初始化tensor +3. 使用tensor初始化tensor ```c++ - Tensor tensor(exist_tensor); + Tensor tensor(exist_tensor); ``` - > 提示: 你可以用` typedef Tensor Tensor4d_X86 `方便定义tensor +>提示: 你可以用` typedef Tensor Tensor4d_X86 `方便定义tensor #### 填充tensor数据区 diff --git a/doc/fluid/advanced_usage/development/gpu_profiling_cn.rst b/doc/fluid/advanced_usage/development/gpu_profiling_cn.rst index f2396716bddd4..481fc916652b7 100644 --- a/doc/fluid/advanced_usage/development/gpu_profiling_cn.rst +++ b/doc/fluid/advanced_usage/development/gpu_profiling_cn.rst @@ -63,10 +63,7 @@ above profilers. 上述的代码片段包含了两种方法,您可以任意使用一个或两个来对感兴趣的代码段做性能分析。 1. :code:`REGISTER_TIMER_INFO` 是一个内置的定时器封装,可以用来计算CPU函数或cuda内核的时间消耗。 - -2. :code:`REGISTER_GPU_PROFILER` is a general purpose wrapper object of :code:`cudaProfilerStart` and :code:`cudaProfilerStop` to avoid -program crashes when CPU version of PaddlePaddle invokes them. - +2. :code:`REGISTER_GPU_PROFILER` 是 :code:`cudaProfilerStart` 和 :code:`cudaProfilerStop` 的通用包装对象,避免当CPU版本的PaddlePaddle调用它们时程序崩溃。 3. :code:`REGISTER_GPU_PROFILER` 是一个封装对象,封装了 :code:`cudaProfilerStart` 和 :code:`cudaProfileStop` 两个操作;同时其内部实现可以避免纯CPU版本PaddlePaddle在执行本语句时发生崩溃。 您会在接下来的部分中获得更多的细节介绍。 diff --git a/doc/fluid/user_guides/howto/inference/native_infer.md b/doc/fluid/user_guides/howto/inference/native_infer.md index b35130bdd8d73..9a82c2982e9b8 100644 --- a/doc/fluid/user_guides/howto/inference/native_infer.md +++ b/doc/fluid/user_guides/howto/inference/native_infer.md @@ -75,26 +75,26 @@ CHECK(predictor->Run(slots, &outputs)); `PaddleBuf` 在内存管理方面有两种模式: 1. 自动分配和管理内存 - -```c++ -int some_size = 1024; -PaddleTensor tensor; -tensor.data.Resize(some_size); -``` + + ```c++ + int some_size = 1024; + PaddleTensor tensor; + tensor.data.Resize(some_size); + ``` 2. 外部内存传入 - -```c++ -int some_size = 1024; -// 用户外部分配内存并保证 PaddleTensor 使用过程中,内存一直可用 -void* memory = new char[some_size]; - -tensor.data.Reset(memory, some_size); -// ... - -// 用户最后需要自行删除内存以避免内存泄漏 -delete[] memory; -``` + ```c++ + int some_size = 1024; + // 用户外部分配内存并保证 PaddleTensor 使用过程中,内存一直可用 + void* memory = new char[some_size]; + + tensor.data.Reset(memory, some_size); + // ... + + // 用户最后需要自行删除内存以避免内存泄漏 + + delete[] memory; + ``` 两种模式中,第一种比较方便;第二种则可以严格控制内存的管理,便于与 `tcmalloc` 等库的集成。 diff --git a/doc/fluid/user_guides/howto/inference/paddle_tensorrt_infer.md b/doc/fluid/user_guides/howto/inference/paddle_tensorrt_infer.md index 30f1a915953c7..111c84395dfae 100644 --- a/doc/fluid/user_guides/howto/inference/paddle_tensorrt_infer.md +++ b/doc/fluid/user_guides/howto/inference/paddle_tensorrt_infer.md @@ -113,12 +113,12 @@ int main() { **原始网络**

- +

**转换的网络**

- +