Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[progress] lstm and gru runtime switch SIMD #1714

Closed
wants to merge 11 commits into from

Conversation

gangliao
Copy link
Contributor

@gangliao gangliao commented Mar 28, 2017

paddle当前avx代码还比较多,只有一步一步修改成runtime switch了。

这里是lstm 和 gru的,还在测试中... 同一份代码编译两份指令,运行时动态的切换

Scanning dependencies of target avx_rnn
[ 24%] Building CXX object paddle/cuda/CMakeFiles/avx_rnn.dir/src/simd_gru_op.cc.o
[ 25%] Building CXX object paddle/cuda/CMakeFiles/avx_rnn.dir/src/simd_gru.cc.o
[ 25%] Building CXX object paddle/cuda/CMakeFiles/avx_rnn.dir/src/simd_lstm_op.cc.o
[ 25%] Building CXX object paddle/cuda/CMakeFiles/avx_rnn.dir/src/simd_lstm.cc.o
Linking CXX static library libavx_rnn.a
[ 25%] Built target avx_rnn
Scanning dependencies of target naive_rnn
[ 26%] Building CXX object paddle/cuda/CMakeFiles/naive_rnn.dir/src/simd_gru_op.cc.o
[ 26%] Building CXX object paddle/cuda/CMakeFiles/naive_rnn.dir/src/simd_gru.cc.o
[ 26%] Building CXX object paddle/cuda/CMakeFiles/naive_rnn.dir/src/simd_lstm_op.cc.o
[ 26%] Building CXX object paddle/cuda/CMakeFiles/naive_rnn.dir/src/simd_lstm.cc.o
Linking CXX static library libnaive_rnn.a
[ 26%] Built target naive_rnn
Scanning dependencies of target paddle_cuda

gpu的还没有加。。

@gangliao gangliao requested review from Xreki and hedaoyuan March 28, 2017 11:30
@gangliao gangliao changed the title lstm and gru runtime switch SIMD [progress] lstm and gru runtime switch SIMD Mar 28, 2017
Copy link
Collaborator

@wangkuiyi wangkuiyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

学习了!赞!

没有测试过,只是努力学了CMakeLists文件的写法,以及学习了逐步分而治之的解法。

赞细致的C++ style。

@@ -205,6 +205,22 @@ typedef struct {
size_t nnz;
} _hl_sparse_matrix_s, *hl_sparse_matrix_s;

/// sigmoid maximum threshold
#define SIGMOID_THRESHOLD_MIN -40.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constant value是不是用

const double kSigmoidRangeMin = -40.0;
const double kSigmoidRangeMax = 13.0;

这样比较好?编译的时候有类型检查。

Copy link
Contributor

@hedaoyuan hedaoyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修改的地方比较多,大概解释一下code refine的思路。最好是解释一下原来的code逻辑,比如包含在那些文件中,怎么编译;refine后包含在哪些文件中,怎么编译。
另外,refine之后的命名还需要在看一下,simd_gru_op.cc,simd_lstm_op.cc里面也包含了非AVX的代码,simd命名不是很合适。

@@ -29,17 +29,13 @@
(this is the zlib license)
*/

#include "simd_math.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文件不能修改名字,最好也不要修改内容。另外,没有看到simd_math.h文件。

endif()

target_link_libraries(paddle_cuda naive_rnn avx_rnn)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这条命令的目的应该是把naive_rnnavx_rnn这两个库合并到paddle_cuda库把,target_link_libraries好像没有这个功能。

set(CPU_SOURCES
src/hl_cpu_recurrent.cc
src/hl_dso_loader.cc
src/hl_warpctc_wrap.cc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WITH_GPU的时候,src/hl_warpctc_wrap.cc的编译也需要定义宏__NVCC__,因为需要给warp-ctc设置stream

@luotao1
Copy link
Contributor

luotao1 commented Feb 1, 2019

感谢您给PaddlePaddle贡献代码。由于Paddle V1/V2版本已不再维护,相关代码也已从develop分支上删除,因此关闭您的PR,欢迎您向Paddle最新版-Fluid贡献代码。
Thanks for contributing to PaddlePaddle! Since V1/V2 will not be maintained anymore, and related codes have been deleted from develop branch as well, we close this PR. Welcome to contribute to Fluid——the latest version of PaddlePaddle.

@luotao1 luotao1 closed this Feb 1, 2019
zhangyuqin1998 pushed a commit to zhangyuqin1998/Paddle that referenced this pull request Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants