Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

转换规则 No.48 RNNBase #134

Merged
merged 1 commit into from
Aug 3, 2023
Merged

Conversation

RedContritio
Copy link
Contributor

@paddle-bot
Copy link

paddle-bot bot commented Jun 27, 2023

Thanks for your contribution!

paconvert/api_matcher.py Outdated Show resolved Hide resolved
@luotao1
Copy link
Collaborator

luotao1 commented Jul 7, 2023

请解决下冲突

paconvert/api_matcher.py Outdated Show resolved Hide resolved
paconvert/api_matcher.py Outdated Show resolved Hide resolved
tests/test_nn_layer_rnn_RNNBase.py Show resolved Hide resolved
if "nonlinearity" in kwargs:
kwargs["activation"] = kwargs.pop("nonlinearity")

if "mode" in kwargs:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

除了这两个判断:
1.判断mode是否为LSTM、GRU
2.判断bidirectional=True

其他地方我觉得都可以用GenericMatcher来实现,分别通过unsupport_args、kwargs_change的json配置就可以,包括bias

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

处理了 batch_firstmodebidirectional 三个参数。有个尚存的问题就是,如果 mode 指定为变量,如

import torch
import torch.nn as nn

mode = "LSTM"
model = torch.nn.RNNBase(mode, 16, 32, bidirectional=False)

就会无法识别,只能处理常量。其他两个量是 boolean 所以可能影响不大,但是这个是字符串,因此可能会有更大的出错可能性。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯先这么写吧,后面我们会针对这个API支持其他两种常量 'RNN_TANH', 'RNN_RELU

if "nonlinearity" in kwargs:
kwargs["activation"] = kwargs.pop("nonlinearity")

if "mode" in kwargs:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯先这么写吧,后面我们会针对这个API支持其他两种常量 'RNN_TANH', 'RNN_RELU

@zhwesky2010 zhwesky2010 merged commit 1d2f63b into PaddlePaddle:master Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource 快乐开源活动issue与PR status: proposed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants