Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
d19bceb6
P
Paddle
项目概览
Crayon鑫
/
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看板
未验证
提交
d19bceb6
编写于
6月 07, 2021
作者:
王
王明冬
提交者:
GitHub
6月 07, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pack the @op_name@.pbtxt into library. test=develop (#33322)
上级
a01e5133
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
66 addition
and
25 deletion
+66
-25
paddle/fluid/framework/CMakeLists.txt
paddle/fluid/framework/CMakeLists.txt
+12
-2
paddle/fluid/framework/ir/op_compat_sensible_pass_tester.cc
paddle/fluid/framework/ir/op_compat_sensible_pass_tester.cc
+12
-0
paddle/fluid/framework/op_def_api.cc
paddle/fluid/framework/op_def_api.cc
+19
-11
paddle/fluid/framework/op_def_api.h
paddle/fluid/framework/op_def_api.h
+23
-0
paddle/fluid/framework/op_def_api.h.in
paddle/fluid/framework/op_def_api.h.in
+0
-12
未找到文件。
paddle/fluid/framework/CMakeLists.txt
浏览文件 @
d19bceb6
...
...
@@ -29,10 +29,20 @@ add_subdirectory(io)
proto_library
(
framework_proto SRCS framework.proto
)
proto_library
(
op_def_proto SRCS op_def.proto
)
set
(
OP_DEF_FOLDER
"
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/operators/compat/"
)
configure_file
(
"op_def_api.h.in"
"op_def_api.h"
)
cc_library
(
op_def_api SRCS op_def_api.cc DEPS op_def_proto
)
FILE
(
GLOB OP_DEF_FILES
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/operators/compat/*.pbtxt
)
FILE
(
WRITE
${
CMAKE_CURRENT_BINARY_DIR
}
/op_def.pbtxt
"namespace {
\n
"
"const std::unordered_map<std::string, std::string> op_def_map = {
\n
"
)
foreach
(
OP_DEF_FILE
${
OP_DEF_FILES
}
)
FILE
(
READ
${
OP_DEF_FILE
}
OP_DEF_CONTENT
)
get_filename_component
(
OP_NAME
${
OP_DEF_FILE
}
NAME_WE
)
FILE
(
APPEND
${
CMAKE_CURRENT_BINARY_DIR
}
/op_def.pbtxt
"{
\"
${
OP_NAME
}
\"
,R
\"
(
${
OP_DEF_CONTENT
}
)
\"
},
\n
"
)
endforeach
(
OP_DEF_FILE
)
FILE
(
APPEND
${
CMAKE_CURRENT_BINARY_DIR
}
/op_def.pbtxt
"{
\"\"
,
\"\"
}};
\n
}"
)
proto_library
(
heter_service_proto SRCS heter_service.proto
)
proto_library
(
data_feed_proto SRCS data_feed.proto
)
proto_library
(
trainer_desc_proto SRCS trainer_desc.proto DEPS framework_proto
...
...
paddle/fluid/framework/ir/op_compat_sensible_pass_tester.cc
浏览文件 @
d19bceb6
...
...
@@ -91,6 +91,18 @@ TEST(OpCompatSensiblePass, compatOpAttribute) {
delete
info
.
checker_
;
}
TEST
(
OpCompatSensiblePass
,
opDefNotFound
)
{
OpCompat
compat
(
"fc_1"
);
OpDesc
fc_op
;
compat
.
Judge
(
fc_op
);
OpCompat
compat_1
(
""
);
compat_1
.
Judge
(
fc_op
);
}
TEST
(
OpCompatSensiblePass
,
compatOpAttributeOptional
)
{
OpCompat
compat
(
"fc"
);
compat
.
AddAttr
(
"activation_type"
)
...
...
paddle/fluid/framework/op_def_api.cc
浏览文件 @
d19bceb6
...
...
@@ -32,6 +32,14 @@
#include "io/fs.h"
#include "paddle/fluid/framework/op_def.pb.h"
/*
// op_def.pbtxt
namespace {
const std::unordered_map<std::string, std::std::string> op_def_map = {...};
}
*/
#include "paddle/fluid/framework/op_def.pbtxt" //NOLINT
namespace
paddle
{
namespace
framework
{
...
...
@@ -42,20 +50,20 @@ const proto::OpDef& GetOpDef(const std::string& op_name) {
std
::
lock_guard
<
std
::
mutex
>
lk
(
mtx
);
if
(
ops_definition
.
find
(
op_name
)
==
ops_definition
.
end
())
{
proto
::
OpDef
op_def
;
std
::
string
op_path
=
OP_DEF_FOLDER
+
op_name
+
".pbtxt"
;
int
fd
=
open
(
op_path
.
c_str
(),
O_RDONLY
);
if
(
fd
==
-
1
)
{
LOG
(
WARNING
)
<<
op_path
<<
" open failed!"
;
if
(
op_def_map
.
find
(
op_name
)
==
op_def_map
.
end
())
{
LOG
(
WARNING
)
<<
op_name
<<
".pbtxt not exist!"
;
}
else
{
::
google
::
protobuf
::
io
::
FileInputStream
*
input
=
new
::
google
::
protobuf
::
io
::
FileInputStream
(
fd
);
if
(
!::
google
::
protobuf
::
TextFormat
::
Parse
(
input
,
&
op_def
))
{
LOG
(
WARNING
)
<<
"Failed to parse "
<<
op_path
;
if
(
!::
google
::
protobuf
::
TextFormat
::
ParseFromString
(
op_def_map
.
at
(
op_name
),
&
op_def
))
{
LOG
(
WARNING
)
<<
"Failed to parse "
<<
op_name
;
}
delete
input
;
close
(
fd
);
}
ops_definition
.
emplace
(
std
::
make_pair
(
op_name
,
std
::
move
(
op_def
)));
if
(
op_def
.
type
()
!=
op_name
)
{
LOG
(
WARNING
)
<<
op_name
<<
".pbtxt has error type :"
<<
op_def
.
type
();
ops_definition
.
emplace
(
std
::
make_pair
(
op_name
,
proto
::
OpDef
()));
}
else
{
ops_definition
.
emplace
(
std
::
make_pair
(
op_name
,
std
::
move
(
op_def
)));
}
}
}
return
ops_definition
.
at
(
op_name
);
...
...
paddle/fluid/framework/op_def_api.h
0 → 100644
浏览文件 @
d19bceb6
// Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include "paddle/fluid/framework/op_def.pb.h"
namespace
paddle
{
namespace
framework
{
const
proto
::
OpDef
&
GetOpDef
(
const
std
::
string
&
op_name
);
}
}
paddle/fluid/framework/op_def_api.h.in
已删除
100644 → 0
浏览文件 @
a01e5133
// the folder of pbtxt with op attribute definition
#pragma once
#include "paddle/fluid/framework/op_def.pb.h"
#define OP_DEF_FOLDER "@OP_DEF_FOLDER@"
namespace paddle {
namespace framework {
const proto::OpDef& GetOpDef(const std::string& op_name);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录