Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
csdn_franckjun
Paddle
提交
ad78a21e
P
Paddle
项目概览
csdn_franckjun
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
ad78a21e
编写于
12月 29, 2021
作者:
Z
Zhanlue Yang
提交者:
GitHub
12月 29, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added copy_if_different for eager code generator (#38562)
上级
ecb8c184
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
39 addition
and
18 deletion
+39
-18
paddle/fluid/eager/auto_code_generator/CMakeLists.txt
paddle/fluid/eager/auto_code_generator/CMakeLists.txt
+25
-0
paddle/fluid/eager/auto_code_generator/eager_generator.cc
paddle/fluid/eager/auto_code_generator/eager_generator.cc
+14
-18
未找到文件。
paddle/fluid/eager/auto_code_generator/CMakeLists.txt
浏览文件 @
ad78a21e
...
...
@@ -16,6 +16,15 @@ execute_process(
COMMAND
"
${
PYTHON_EXECUTABLE
}
"
"
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/eager/auto_code_generator/generate_file_structures.py"
"
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/eager/"
)
set
(
tmp_dygraph_forward_h_path
"
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/eager/api/generated/fluid_generated/dygraph_forward_api.tmp.h"
)
set
(
tmp_dygraph_forward_cc_path
"
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/eager/api/generated/fluid_generated/forwards/dygraph_forward_functions.tmp.cc"
)
set
(
tmp_dygraph_node_h_path
"
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/eager/api/generated/fluid_generated/nodes/nodes.tmp.h"
)
set
(
tmp_dygraph_node_cc_path
"
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/eager/api/generated/fluid_generated/nodes/nodes.tmp.cc"
)
set
(
dygraph_forward_h_path
"
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/eager/api/generated/fluid_generated/dygraph_forward_api.h"
)
set
(
dygraph_forward_cc_path
"
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/eager/api/generated/fluid_generated/forwards/dygraph_forward_functions.cc"
)
set
(
dygraph_node_h_path
"
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/eager/api/generated/fluid_generated/nodes/nodes.h"
)
set
(
dygraph_node_cc_path
"
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/eager/api/generated/fluid_generated/nodes/nodes.cc"
)
if
(
WIN32
)
set
(
EAGER_CODEGEN_DEPS eager_generator
)
if
(
"
${
CMAKE_GENERATOR
}
"
STREQUAL
"Ninja"
)
...
...
@@ -48,6 +57,14 @@ if(WIN32)
add_custom_target
(
eager_codegen
COMMAND
"
${
eager_generator_path
}
/eager_generator.exe"
"
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/eager/api/generated/fluid_generated"
COMMAND
${
CMAKE_COMMAND
}
-E copy_if_different
${
tmp_dygraph_forward_h_path
}
${
dygraph_forward_h_path
}
COMMENT
"copy_if_different
${
tmp_dygraph_forward_h_path
}
to
${
dygraph_forward_h_path
}
"
COMMAND
${
CMAKE_COMMAND
}
-E copy_if_different
${
tmp_dygraph_forward_cc_path
}
${
dygraph_forward_cc_path
}
COMMENT
"copy_if_different
${
tmp_dygraph_forward_cc_path
}
to
${
dygraph_forward_cc_path
}
"
COMMAND
${
CMAKE_COMMAND
}
-E copy_if_different
${
tmp_dygraph_node_h_path
}
${
dygraph_node_h_path
}
COMMENT
"copy_if_different
${
tmp_dygraph_node_h_path
}
to
${
dygraph_node_h_path
}
"
COMMAND
${
CMAKE_COMMAND
}
-E copy_if_different
${
tmp_dygraph_node_cc_path
}
${
dygraph_node_cc_path
}
COMMENT
"copy_if_different
${
tmp_dygraph_node_cc_path
}
to
${
dygraph_node_cc_path
}
"
DEPENDS
${
EAGER_CODEGEN_DEPS
}
VERBATIM
)
else
()
...
...
@@ -55,6 +72,14 @@ else()
COMMAND
${
CMAKE_COMMAND
}
-E env
"LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:
${
CMAKE_CURRENT_BINARY_DIR
}
/../../pybind"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/eager_generator"
"
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/eager/api/generated/fluid_generated"
COMMAND
${
CMAKE_COMMAND
}
-E copy_if_different
${
tmp_dygraph_forward_h_path
}
${
dygraph_forward_h_path
}
COMMENT
"copy_if_different
${
tmp_dygraph_forward_h_path
}
to
${
dygraph_forward_h_path
}
"
COMMAND
${
CMAKE_COMMAND
}
-E copy_if_different
${
tmp_dygraph_forward_cc_path
}
${
dygraph_forward_cc_path
}
COMMENT
"copy_if_different
${
tmp_dygraph_forward_cc_path
}
to
${
dygraph_forward_cc_path
}
"
COMMAND
${
CMAKE_COMMAND
}
-E copy_if_different
${
tmp_dygraph_node_h_path
}
${
dygraph_node_h_path
}
COMMENT
"copy_if_different
${
tmp_dygraph_node_h_path
}
to
${
dygraph_node_h_path
}
"
COMMAND
${
CMAKE_COMMAND
}
-E copy_if_different
${
tmp_dygraph_node_cc_path
}
${
dygraph_node_cc_path
}
COMMENT
"copy_if_different
${
tmp_dygraph_node_cc_path
}
to
${
dygraph_node_cc_path
}
"
DEPENDS eager_generator
VERBATIM
)
endif
()
paddle/fluid/eager/auto_code_generator/eager_generator.cc
浏览文件 @
ad78a21e
...
...
@@ -1847,19 +1847,15 @@ static std::string GenerateDygraphHFileIncludes() {
return
dygraph_forward_api_includes_str
;
}
static
void
GenerateForwardHFile
(
const
std
::
string
&
output_dir
,
static
void
GenerateForwardHFile
(
const
std
::
string
&
dygraph_forward_api_path
,
const
std
::
string
&
dygraph_forward_api_str
)
{
std
::
string
dygraph_forward_api_path
=
output_dir
+
"/dygraph_forward_api.h"
;
std
::
ofstream
forward_header_stream
(
dygraph_forward_api_path
,
std
::
ios
::
out
);
forward_header_stream
<<
dygraph_forward_api_str
;
forward_header_stream
.
close
();
}
static
void
GenerateForwardDygraphFile
(
const
std
::
string
&
output_dir
,
static
void
GenerateForwardDygraphFile
(
const
std
::
string
&
forward_cc_path
,
const
std
::
string
&
fwd_function_str
)
{
std
::
string
forwards_dir
=
output_dir
+
"/forwards/"
;
std
::
string
forward_cc_filename
=
"dygraph_forward_functions.cc"
;
std
::
string
forward_cc_path
=
forwards_dir
+
forward_cc_filename
;
const
char
*
FORWARD_INCLUDE_TEMPLATE
=
"#include "
"
\"
paddle/fluid/eager/api/generated/fluid_generated/"
...
...
@@ -1876,11 +1872,8 @@ static void GenerateForwardDygraphFile(const std::string& output_dir,
forward_cc_stream
.
close
();
}
static
void
GenerateNodeHFile
(
const
std
::
string
&
output_dir
,
static
void
GenerateNodeHFile
(
const
std
::
string
&
node_h_path
,
const
std
::
string
&
grad_node_str
)
{
std
::
string
nodes_dir
=
output_dir
+
"/nodes/"
;
std
::
string
node_h_filename
=
"nodes.h"
;
std
::
string
node_h_path
=
nodes_dir
+
node_h_filename
;
std
::
string
node_h_include_str
=
"#pragma once
\n
"
"#include
\"
paddle/fluid/eager/tensor_wrapper.h
\"\n
"
...
...
@@ -1892,11 +1885,8 @@ static void GenerateNodeHFile(const std::string& output_dir,
node_h_stream
.
close
();
}
static
void
GenerateNodeCCFile
(
const
std
::
string
&
output_dir
,
static
void
GenerateNodeCCFile
(
const
std
::
string
&
node_cc_path
,
const
std
::
string
&
grad_function_str
)
{
std
::
string
nodes_dir
=
output_dir
+
"/nodes/"
;
std
::
string
node_cc_filename
=
"nodes.cc"
;
std
::
string
node_cc_path
=
nodes_dir
+
node_cc_filename
;
const
char
*
NODE_CC_INCLUDE_TEMPLATE
=
"#include
\"
glog/logging.h
\"\n
"
"#include
\"
paddle/pten/api/all.h
\"\n
"
...
...
@@ -2026,18 +2016,24 @@ static void DygraphCodeGeneration(const std::string& output_dir) {
}
VLOG
(
6
)
<<
"-------- GenerateDygraphForwardCCFile -------"
;
std
::
string
forward_cc_path
=
output_dir
+
"/forwards/dygraph_forward_functions.tmp.cc"
;
fwd_function_str
+=
"
\n
"
;
fwd_function_str
+=
GenerateCoreOpsReturnsInfo
();
GenerateForwardDygraphFile
(
output_dir
,
fwd_function_str
);
GenerateForwardDygraphFile
(
forward_cc_path
,
fwd_function_str
);
VLOG
(
6
)
<<
"-------- GenerateForwardHFile -------"
;
GenerateForwardHFile
(
output_dir
,
dygraph_forward_api_str
);
std
::
string
dygraph_forward_api_path
=
output_dir
+
"/dygraph_forward_api.tmp.h"
;
GenerateForwardHFile
(
dygraph_forward_api_path
,
dygraph_forward_api_str
);
VLOG
(
6
)
<<
"-------- GenerateNodeHFile -------"
;
GenerateNodeHFile
(
output_dir
,
grad_node_h_str
);
std
::
string
node_h_path
=
output_dir
+
"/nodes/nodes.tmp.h"
;
GenerateNodeHFile
(
node_h_path
,
grad_node_h_str
);
VLOG
(
6
)
<<
"-------- GenerateNodeCCFile -------"
;
GenerateNodeCCFile
(
output_dir
,
grad_node_cc_str
);
std
::
string
node_cc_path
=
output_dir
+
"/nodes/nodes.tmp.cc"
;
GenerateNodeCCFile
(
node_cc_path
,
grad_node_cc_str
);
}
static
void
PrepareAttrMapForOps
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录