Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wjd2002
Ncnn
提交
f8e32aba
N
Ncnn
项目概览
wjd2002
/
Ncnn
10 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
Ncnn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
f8e32aba
编写于
4月 17, 2023
作者:
N
nihui
提交者:
GitHub
4月 17, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix pnnx gru rnn with optional output, fix #4608 (#4631)
上级
d87e895a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
27 addition
and
9 deletion
+27
-9
tools/pnnx/src/ir.cpp
tools/pnnx/src/ir.cpp
+18
-0
tools/pnnx/tests/test_nn_GRU.py
tools/pnnx/tests/test_nn_GRU.py
+3
-3
tools/pnnx/tests/test_nn_LSTM.py
tools/pnnx/tests/test_nn_LSTM.py
+3
-3
tools/pnnx/tests/test_nn_RNN.py
tools/pnnx/tests/test_nn_RNN.py
+3
-3
未找到文件。
tools/pnnx/src/ir.cpp
浏览文件 @
f8e32aba
...
...
@@ -1873,6 +1873,24 @@ int Graph::python(const std::string& pypath, const std::string& pnnxbinpath)
}
fprintf
(
pyfp
,
"]
\n
"
);
}
else
if
(
op
->
type
==
"nn.GRU"
||
op
->
type
==
"nn.RNN"
)
{
if
(
op
->
outputs
.
size
()
==
1
)
{
fprintf
(
pyfp
,
"v_%s, _"
,
sanitize_identifier
(
op
->
outputs
[
0
]
->
name
).
c_str
());
}
else
{
fprintf
(
pyfp
,
"v_%s, v_%s"
,
sanitize_identifier
(
op
->
outputs
[
0
]
->
name
).
c_str
(),
sanitize_identifier
(
op
->
outputs
[
1
]
->
name
).
c_str
());
}
fprintf
(
pyfp
,
" = self.%s("
,
sanitize_identifier
(
op
->
name
).
c_str
());
fprintf
(
pyfp
,
"v_%s"
,
sanitize_identifier
(
op
->
inputs
[
0
]
->
name
).
c_str
());
if
(
op
->
inputs
.
size
()
==
2
)
{
fprintf
(
pyfp
,
", v_%s"
,
sanitize_identifier
(
op
->
inputs
[
1
]
->
name
).
c_str
());
}
fprintf
(
pyfp
,
")
\n
"
);
}
else
if
(
op
->
type
==
"nn.LSTM"
)
{
if
(
op
->
outputs
.
size
()
==
1
)
...
...
tools/pnnx/tests/test_nn_GRU.py
浏览文件 @
f8e32aba
...
...
@@ -32,15 +32,15 @@ class Model(nn.Module):
def
forward
(
self
,
x
,
y
):
x0
,
h0
=
self
.
gru_0_0
(
x
)
x1
,
h1
=
self
.
gru_0_1
(
x0
)
x1
,
_
=
self
.
gru_0_1
(
x0
)
x2
,
h2
=
self
.
gru_0_2
(
x1
)
x3
,
h3
=
self
.
gru_0_3
(
x1
,
h2
)
y0
,
h4
=
self
.
gru_1_0
(
y
)
y1
,
h5
=
self
.
gru_1_1
(
y0
)
y1
,
_
=
self
.
gru_1_1
(
y0
)
y2
,
h6
=
self
.
gru_1_2
(
y1
)
y3
,
h7
=
self
.
gru_1_3
(
y1
,
h6
)
return
x2
,
x3
,
h0
,
h
1
,
h2
,
h3
,
y2
,
y3
,
h4
,
h5
,
h6
,
h7
return
x2
,
x3
,
h0
,
h
2
,
h3
,
y2
,
y3
,
h4
,
h6
,
h7
def
test
():
net
=
Model
()
...
...
tools/pnnx/tests/test_nn_LSTM.py
浏览文件 @
f8e32aba
...
...
@@ -32,15 +32,15 @@ class Model(nn.Module):
def
forward
(
self
,
x
,
y
):
x0
,
(
h0
,
c0
)
=
self
.
lstm_0_0
(
x
)
x1
,
(
h1
,
c1
)
=
self
.
lstm_0_1
(
x0
)
x1
,
_
=
self
.
lstm_0_1
(
x0
)
x2
,
(
h2
,
c2
)
=
self
.
lstm_0_2
(
x1
)
x3
,
(
h3
,
c3
)
=
self
.
lstm_0_3
(
x2
,
(
h2
,
c2
))
y0
,
(
h4
,
c4
)
=
self
.
lstm_1_0
(
y
)
y1
,
(
h5
,
c5
)
=
self
.
lstm_1_1
(
y0
)
y1
,
_
=
self
.
lstm_1_1
(
y0
)
y2
,
(
h6
,
c6
)
=
self
.
lstm_1_2
(
y1
)
y3
,
(
h7
,
c7
)
=
self
.
lstm_1_3
(
y2
,
(
h6
,
c6
))
return
x2
,
x3
,
h0
,
h
1
,
h2
,
h3
,
c0
,
c1
,
c2
,
c3
,
y2
,
y3
,
h4
,
h5
,
h6
,
h7
,
c4
,
c5
,
c6
,
c7
return
x2
,
x3
,
h0
,
h
2
,
h3
,
c0
,
c2
,
c3
,
y2
,
y3
,
h4
,
h6
,
h7
,
c4
,
c6
,
c7
def
test
():
net
=
Model
()
...
...
tools/pnnx/tests/test_nn_RNN.py
浏览文件 @
f8e32aba
...
...
@@ -32,15 +32,15 @@ class Model(nn.Module):
def
forward
(
self
,
x
,
y
):
x0
,
h0
=
self
.
rnn_0_0
(
x
)
x1
,
h1
=
self
.
rnn_0_1
(
x0
)
x1
,
_
=
self
.
rnn_0_1
(
x0
)
x2
,
h2
=
self
.
rnn_0_2
(
x1
)
x3
,
h3
=
self
.
rnn_0_3
(
x1
,
h2
)
y0
,
h4
=
self
.
rnn_1_0
(
y
)
y1
,
h5
=
self
.
rnn_1_1
(
y0
)
y1
,
_
=
self
.
rnn_1_1
(
y0
)
y2
,
h6
=
self
.
rnn_1_2
(
y1
)
y3
,
h7
=
self
.
rnn_1_3
(
y1
,
h6
)
return
x2
,
x3
,
h0
,
h
1
,
h2
,
h3
,
y2
,
y3
,
h4
,
h5
,
h6
,
h7
return
x2
,
x3
,
h0
,
h
2
,
h3
,
y2
,
y3
,
h4
,
h6
,
h7
def
test
():
net
=
Model
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录