Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
ee56906e
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
ee56906e
编写于
4月 26, 2022
作者:
L
Leo Chen
提交者:
GitHub
4月 26, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fit for printing cinn_launch op (#42141)
* fit for printing cinn_launch op * update boost::variant caster for bytes
上级
18e9aafb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
48 addition
and
5 deletion
+48
-5
paddle/fluid/pybind/pybind.cc
paddle/fluid/pybind/pybind.cc
+12
-1
paddle/fluid/pybind/pybind_boost_headers.h
paddle/fluid/pybind/pybind_boost_headers.h
+21
-3
python/paddle/fluid/framework.py
python/paddle/fluid/framework.py
+15
-1
未找到文件。
paddle/fluid/pybind/pybind.cc
浏览文件 @
ee56906e
...
...
@@ -1921,7 +1921,7 @@ All parameter, weight, gradient are variables in Paddle.
Prune the backward part of a program, mostly called in
program.clone(for_test=True).
Args:
Args:
program (ProgramDesc): The original program.
Returns:
...
...
@@ -1930,6 +1930,17 @@ All parameter, weight, gradient are variables in Paddle.
which contains the id pair of pruned block and corresponding
origin block.
)DOC"
);
m
.
def
(
"get_readable_comile_key"
,
[](
const
OpDesc
&
op_desc
)
{
auto
compilation_key
=
BOOST_GET_CONST
(
std
::
string
,
op_desc
.
GetAttr
(
"compilation_key"
));
VLOG
(
4
)
<<
std
::
hash
<
std
::
string
>
{}(
compilation_key
)
<<
" "
<<
compilation_key
.
size
();
proto
::
ProgramDesc
desc
;
desc
.
ParseFromString
(
compilation_key
);
auto
s
=
desc
.
DebugString
();
VLOG
(
4
)
<<
s
;
return
s
;
});
m
.
def
(
"empty_var_name"
,
[]()
{
return
std
::
string
(
framework
::
kEmptyVarName
);
});
m
.
def
(
"grad_var_suffix"
,
...
...
paddle/fluid/pybind/pybind_boost_headers.h
浏览文件 @
ee56906e
...
...
@@ -45,10 +45,28 @@ struct PYBIND11_HIDDEN paddle_variant_caster_visitor
paddle_variant_caster_visitor
(
return_value_policy
policy
,
handle
parent
)
:
policy
(
policy
),
parent
(
parent
)
{}
template
<
class
T
>
handle
operator
()(
T
const
&
src
)
const
{
template
<
class
T
,
typename
std
::
enable_if
<!
std
::
is_same
<
T
,
std
::
string
>
::
value
,
bool
>::
type
*
=
nullptr
>
handle
operator
()(
T
const
&
src
)
const
{
return
make_caster
<
T
>::
cast
(
src
,
policy
,
parent
);
}
template
<
class
T
,
typename
std
::
enable_if
<
std
::
is_same
<
T
,
std
::
string
>
::
value
,
bool
>::
type
*
=
nullptr
>
handle
operator
()(
T
const
&
src
)
const
{
try
{
return
make_caster
<
T
>::
cast
(
src
,
policy
,
parent
);
}
catch
(
std
::
exception
&
ex
)
{
VLOG
(
4
)
<<
ex
.
what
();
VLOG
(
4
)
<<
src
;
// UnicodeDecodeError, src is not utf-8 encoded
// see details:
// https://github.com/pybind/pybind11/blob/master/docs/advanced/cast/strings.rst
return
PYBIND11_BYTES_FROM_STRING_AND_SIZE
(
src
.
data
(),
src
.
size
());
}
}
};
template
<
class
Variant
>
...
...
@@ -105,7 +123,7 @@ struct paddle_variant_caster<V<Ts...>> {
return
load_success_
;
}
static
handle
cast
(
Type
const
&
src
,
return_value_policy
policy
,
static
handle
cast
(
Type
const
&
src
,
return_value_policy
policy
,
handle
parent
)
{
paddle_variant_caster_visitor
visitor
(
policy
,
parent
);
return
boost
::
apply_visitor
(
visitor
,
src
);
...
...
python/paddle/fluid/framework.py
浏览文件 @
ee56906e
...
...
@@ -2863,8 +2863,22 @@ class Operator(object):
attrs_str
+=
", "
continue
# it is bytes of serialized protobuf
if
self
.
type
==
'cinn_launch'
and
name
==
'compilation_key'
:
# value = core.get_readable_comile_key(self.desc)
v
=
self
.
desc
.
attr
(
name
)
prog
=
Program
()
prog
=
prog
.
parse_from_string
(
v
)
s
=
prog
.
_to_readable_code
()
lines
=
s
.
split
(
'
\n
'
)
value
=
'
\n
'
.
join
([
' '
+
line
for
line
in
lines
])
value
=
'
\n
'
+
value
else
:
value
=
self
.
desc
.
attr
(
name
)
a
=
"{name} = {value}"
.
format
(
name
=
name
,
type
=
attr_type
,
value
=
self
.
desc
.
attr
(
name
))
name
=
name
,
type
=
attr_type
,
value
=
value
)
attrs_str
+=
a
if
i
!=
len
(
attr_names
)
-
1
:
attrs_str
+=
", "
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录