Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
de3e9c30
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2305
Star
20932
Fork
5423
代码
文件
提交
分支
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看板
未验证
提交
de3e9c30
编写于
7月 21, 2023
作者:
K
kangguangli
提交者:
GitHub
7月 21, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[NewIR][BugFix] fix empty_var_name problem (#55546)
* fix empty_var_name problem * fix coverage ci * fix coverage ci
上级
4b3ac86d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
36 addition
and
29 deletion
+36
-29
paddle/fluid/ir_adaptor/translator/op_translator.cc
paddle/fluid/ir_adaptor/translator/op_translator.cc
+8
-9
paddle/fluid/ir_adaptor/translator/program_translator.cc
paddle/fluid/ir_adaptor/translator/program_translator.cc
+1
-0
test/ir/new_ir/test_special_op_translator.py
test/ir/new_ir/test_special_op_translator.py
+27
-20
未找到文件。
paddle/fluid/ir_adaptor/translator/op_translator.cc
浏览文件 @
de3e9c30
...
...
@@ -480,14 +480,7 @@ OpTranscriber::GenerateOperationOutput(ir::IrContext* ctx,
continue
;
}
const
auto
&
origin_legacy_output_vars
=
op_desc
.
Output
(
legacy_output_name
);
std
::
vector
<
std
::
string
>
legacy_output_vars
;
std
::
copy_if
(
origin_legacy_output_vars
.
begin
(),
origin_legacy_output_vars
.
end
(),
std
::
back_inserter
(
legacy_output_vars
),
[](
const
auto
&
var_name
)
{
return
var_name
!=
kEmptyVarName
;
});
const
auto
&
legacy_output_vars
=
op_desc
.
Output
(
legacy_output_name
);
bool
is_vector
=
(
info
.
type_name
.
find
(
"VectorType"
)
!=
std
::
string
::
npos
);
// Specially process TensorArray, this because we cannot distinguish it with
...
...
@@ -534,6 +527,11 @@ OpTranscriber::GenerateOperationOutput(ir::IrContext* ctx,
<<
info
.
type_name
<<
" "
<<
legacy_output_name
;
std
::
vector
<
ir
::
Type
>
types
;
for
(
const
auto
&
var_name
:
legacy_output_vars
)
{
if
(
var_name
==
kEmptyVarName
)
{
types
.
push_back
(
ir
::
Type
(
nullptr
));
arg_to_idx
[
var_name
]
=
cur_output_idx
;
continue
;
}
VarDesc
*
var
=
block
->
FindVarRecursive
(
var_name
);
VLOG
(
10
)
<<
"[output translating]"
<<
"["
<<
op_desc
.
Type
()
<<
"]"
<<
info
.
name
<<
" "
<<
var_name
...
...
@@ -562,7 +560,8 @@ ir::AttributeMap OpTranscriber::TranslateOpAttribute(
for
(
const
auto
&
info
:
op_attr_infos
)
{
auto
legacy_attr_name
=
op_normalizer
.
GetLegacyAttrName
(
op_desc
.
Type
(),
info
.
name
);
VLOG
(
10
)
<<
"[op: "
<<
op_desc
.
Type
()
<<
"][attr] from: "
<<
legacy_attr_name
<<
" to: "
<<
info
.
name
;
if
(
op_desc
.
HasAttr
(
legacy_attr_name
))
{
paddle
::
framework
::
Attribute
legacy_attr
=
op_desc
.
GetAttr
(
legacy_attr_name
);
...
...
paddle/fluid/ir_adaptor/translator/program_translator.cc
浏览文件 @
de3e9c30
...
...
@@ -179,6 +179,7 @@ void ProgramTranslator::SetParameterFromSingleBlock(const BlockDesc& block) {
bool
need_set_parameter_op
=
(
parameter_name_mappings_
.
find
(
var_name
)
!=
parameter_name_mappings_
.
end
());
need_set_parameter_op
&=
(
parameter_visited_
.
count
(
var_name
)
==
0
);
need_set_parameter_op
&=
(
param_map_
.
count
(
var_name
)
!=
0
);
if
(
need_set_parameter_op
)
{
ir
::
OpResult
defining_op_result
=
param_map_
[
var_name
].
value
;
ir
::
Operation
*
op
=
InsertSetParamaterOp
(
...
...
test/ir/new_ir/test_special_op_translator.py
浏览文件 @
de3e9c30
...
...
@@ -33,10 +33,7 @@ class TestCastOpTranscriber(unittest.TestCase):
x
=
paddle
.
to_tensor
([
2
,
3
,
4
],
'float64'
)
y
=
paddle
.
cast
(
x
,
'uint8'
)
default_job
=
core
.
Job
(
"default"
)
type_to_program
=
{
"default"
:
main_program
.
desc
}
plan
=
core
.
Plan
([
default_job
],
type_to_program
)
new_exe
=
core
.
StandaloneExecutor
(
place
,
plan
,
new_scope
)
_
=
paddle
.
fluid
.
core
.
translate_newirprogram
(
main_program
.
desc
)
class
TestEmbeddingOpTranscriber
(
unittest
.
TestCase
):
...
...
@@ -53,10 +50,7 @@ class TestEmbeddingOpTranscriber(unittest.TestCase):
)
output
=
embedding
(
x
)
default_job
=
core
.
Job
(
"default"
)
type_to_program
=
{
"default"
:
main_program
.
desc
}
plan
=
core
.
Plan
([
default_job
],
type_to_program
)
new_exe
=
core
.
StandaloneExecutor
(
place
,
plan
,
new_scope
)
_
=
paddle
.
fluid
.
core
.
translate_newirprogram
(
main_program
.
desc
)
class
TestIncrementOpTranscriber
(
unittest
.
TestCase
):
...
...
@@ -70,10 +64,7 @@ class TestIncrementOpTranscriber(unittest.TestCase):
data
=
paddle
.
zeros
(
shape
=
[
1
],
dtype
=
'float32'
)
counter
=
paddle
.
increment
(
data
)
default_job
=
core
.
Job
(
"default"
)
type_to_program
=
{
"default"
:
main_program
.
desc
}
plan
=
core
.
Plan
([
default_job
],
type_to_program
)
new_exe
=
core
.
StandaloneExecutor
(
place
,
plan
,
new_scope
)
_
=
paddle
.
fluid
.
core
.
translate_newirprogram
(
main_program
.
desc
)
class
TestAssignValueOpTranscriber
(
unittest
.
TestCase
):
...
...
@@ -90,10 +81,7 @@ class TestAssignValueOpTranscriber(unittest.TestCase):
stop_gradient
=
False
,
)
default_job
=
core
.
Job
(
"default"
)
type_to_program
=
{
"default"
:
main_program
.
desc
}
plan
=
core
.
Plan
([
default_job
],
type_to_program
)
new_exe
=
core
.
StandaloneExecutor
(
place
,
plan
,
new_scope
)
_
=
paddle
.
fluid
.
core
.
translate_newirprogram
(
main_program
.
desc
)
class
TestRnnOpTranscriber
(
unittest
.
TestCase
):
...
...
@@ -110,10 +98,29 @@ class TestRnnOpTranscriber(unittest.TestCase):
cell
=
paddle
.
nn
.
SimpleRNNCell
(
16
,
32
)
y
,
h
=
cell
(
x
,
prev_h
)
default_job
=
core
.
Job
(
"default"
)
type_to_program
=
{
"default"
:
main_program
.
desc
}
plan
=
core
.
Plan
([
default_job
],
type_to_program
)
new_exe
=
core
.
StandaloneExecutor
(
place
,
plan
,
new_scope
)
_
=
paddle
.
fluid
.
core
.
translate_newirprogram
(
main_program
.
desc
)
class
TestEmptyVarTranslate
(
unittest
.
TestCase
):
def
test_op
(
self
):
place
=
core
.
Place
()
place
.
set_place
(
paddle
.
CPUPlace
())
new_scope
=
paddle
.
static
.
Scope
()
main_program
=
paddle
.
static
.
Program
()
with
paddle
.
static
.
scope_guard
(
new_scope
):
with
paddle
.
static
.
program_guard
(
main_program
):
x1
=
paddle
.
rand
(
shape
=
[
3
,
3
],
dtype
=
"float32"
)
x1
.
stop_gradient
=
False
weight
=
paddle
.
full
(
shape
=
[
3
,
3
],
fill_value
=
"0.5"
,
dtype
=
"float32"
)
y
=
paddle
.
nn
.
functional
.
linear
(
x1
,
weight
)
y
.
stop_gradient
=
True
out1
=
paddle
.
concat
(
x
=
[
x1
,
y
],
axis
=
1
)
out2
=
paddle
.
mean
(
out1
)
sgd_optimizer
=
paddle
.
optimizer
.
SGD
(
learning_rate
=
0.1
)
sgd_optimizer
.
minimize
(
out2
)
_
=
paddle
.
fluid
.
core
.
translate_newirprogram
(
main_program
.
desc
)
class
TestOneHotOpTranscriber
(
unittest
.
TestCase
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录