-
Notifications
You must be signed in to change notification settings - Fork 29
How to build mobile inference library with minimum size #21
Conversation
Merge the updated develop branch |
deployment/build_for_minimum_size.md
Outdated
@@ -0,0 +1,27 @@ | |||
# Build mobile inference library with minimum size | |||
|
|||
In many mobile applications, the size of the executable program will have some requirements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the size of the executable program will have some requirements -> there usually are some limitations to the size of libraries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
deployment/build_for_minimum_size.md
Outdated
# Build mobile inference library with minimum size | ||
|
||
In many mobile applications, the size of the executable program will have some requirements. | ||
Here we explore how to compile the inference library with minimum size. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with minimum size -> for minimum size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
deployment/build_for_minimum_size.md
Outdated
|
||
**Note:** | ||
In the original PaddlePaddle, all computationally relevant code is implemented in Matrix.cpp and BaseMatrix.cu, | ||
this causes the compiled Matrix.o and BaseMatrix.o files to be large and can not be split. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this causes large compiled Matrix.o and BaseMatrix.o files which cannot be split
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
deployment/build_for_minimum_size.md
Outdated
In the original PaddlePaddle, all computationally relevant code is implemented in Matrix.cpp and BaseMatrix.cu, | ||
this causes the compiled Matrix.o and BaseMatrix.o files to be large and can not be split. | ||
The module of Layer can be split, but the Layer forward and backward computing is included in the same file. | ||
The configuration definition in proto has some redundancy. These all will lead to the size of inference library larger. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has some redundancy -> is redundant
And I suggest to move These all will lead to the size of inference library larger.
to line 7, as Three reasons lead to the large size of PaddlePaddle's inference library:
, then list the three reasons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Maybe not only three. I think we can fix this later.
deployment/build_for_minimum_size.md
Outdated
## How to build with minimum size | ||
Here we mainly introduce some optimization in the compilation process to reduce the size of the inference library. These methods are also used in the refactored PaddlePaddle. | ||
|
||
- MinSizeRel: By specify the build type(CMAKE_BUILD_TYPE) as MinSizeRel, the -Os option is used by the compiler during the build for minimum size code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By specify the build type(CMAKE_BUILD_TYPE) as MinSizeRel -> by specifing the build type (CMAKE_BUILD_TYPE
) to MinSizeRel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
deployment/build_for_minimum_size.md
Outdated
- protobuf-lite: With the `--cpp_out lite` option, the generated proto configuration rely on MessageLite instead of Message, | ||
so only libprotobuf-lite is needed for the link, and the size of the final executable file can be reduced. | ||
- whole-archive: In `libpaddle_capi_layers.a` contains all the object file of the layers, need use the `--whole-archive` option to ensure that all layers be linked to the executable file. | ||
But don't forget to use `-no-whole-archive after` after `libpaddle_capi_layers.a`, avoid this option affect other libraries. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reduntant "after": -no-whole-archive after
-> -no-whole-archive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
deployment/build_for_minimum_size.md
Outdated
## How to build with minimum size | ||
Here we mainly introduce some optimization in the compilation process to reduce the size of the inference library. These methods are also used in the refactored PaddlePaddle. | ||
|
||
- MinSizeRel: By specify the build type(CMAKE_BUILD_TYPE) as MinSizeRel, the -Os option is used by the compiler during the build for minimum size code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MinSizeRel: -> Set build type to MinSizeRel
:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
deployment/build_for_minimum_size.md
Outdated
Here we mainly introduce some optimization in the compilation process to reduce the size of the inference library. These methods are also used in the refactored PaddlePaddle. | ||
|
||
- MinSizeRel: By specify the build type(CMAKE_BUILD_TYPE) as MinSizeRel, the -Os option is used by the compiler during the build for minimum size code. | ||
- protobuf-lite: With the `--cpp_out lite` option, the generated proto configuration rely on MessageLite instead of Message, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protobuf-lite: -> Use protobuf-lite
instead of protobuf
:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
deployment/build_for_minimum_size.md
Outdated
- MinSizeRel: By specify the build type(CMAKE_BUILD_TYPE) as MinSizeRel, the -Os option is used by the compiler during the build for minimum size code. | ||
- protobuf-lite: With the `--cpp_out lite` option, the generated proto configuration rely on MessageLite instead of Message, | ||
so only libprotobuf-lite is needed for the link, and the size of the final executable file can be reduced. | ||
- whole-archive: In `libpaddle_capi_layers.a` contains all the object file of the layers, need use the `--whole-archive` option to ensure that all layers be linked to the executable file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whole-archive: -> How to link static libraries:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
deployment/build_for_minimum_size.md
Outdated
- whole-archive: In `libpaddle_capi_layers.a` contains all the object file of the layers, need use the `--whole-archive` option to ensure that all layers be linked to the executable file. | ||
But don't forget to use `-no-whole-archive after` after `libpaddle_capi_layers.a`, avoid this option affect other libraries. | ||
[Here's an example](https://github.com/PaddlePaddle/Mobile/blob/develop/benchmark/tool/C/CMakeLists.txt#L41) | ||
- Shared library: When building a shared library by `libpaddle_capi_layers.a` and `libpaddle_capi_engine.a`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shared library: -> How to generate shared library use PaddlePaddle's static libraries
Perhaps it is still not precise...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
No description provided.