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

Scalar support marking data_type in yaml #40867

Merged
merged 3 commits into from
Mar 25, 2022

Conversation

zyfncg
Copy link
Contributor

@zyfncg zyfncg commented Mar 23, 2022

PR types

Others

PR changes

Others

Describe

Yaml配置中支持为Scalar类型参数指定特定数据类型,标记方式为Scalar(Type), 如Scalar(int) axis

iclementine
iclementine previously approved these changes Mar 24, 2022
Copy link

@iclementine iclementine left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -89,6 +89,11 @@ def parse_input_and_attr(self, api_name, args_config, optional_vars=[]):
attr_types_map = {
'ScalarArray': 'const ScalarArray&',
'Scalar': 'const Scalar&',
'Scalar(int)': 'const Scalar&',
'Scalar(int32)': 'const Scalar&',
Copy link
Contributor

Choose a reason for hiding this comment

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

去掉int32

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

'Scalar(int32)': 'const Scalar&',
'Scalar(int64)': 'const Scalar&',
'Scalar(float)': 'const Scalar&',
'Scalar(dobule)': 'const Scalar&',
'uint8': 'uint8_t',
'int': 'int',
'int32': 'int32_t',
Copy link
Contributor

Choose a reason for hiding this comment

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

同上,统一命名风格,要不和C++类型对齐,要不和DataType的标记类型对齐,避免模棱两可的数据类型命名

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. 对于attribute的写法向C++类型对齐

@@ -37,6 +37,11 @@
'Tensor[]' : 'std::vector<Tensor>',
'Tensor[Tensor[]]' : 'std::vector<std::vector<Tensor>>',
'Scalar' : 'paddle::experimental::Scalar',
'Scalar(int)' : 'paddle::experimental::Scalar',
Copy link
Contributor

Choose a reason for hiding this comment

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

如果细化设计,后续所有类型都需要支持

Copy link
Contributor Author

Choose a reason for hiding this comment

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

目前只支持int,int64_t,float和double四种配置,已基本覆盖目前使用Scalar的attribute类型,后续是否新增需要根据具体需求来决定。

Copy link
Contributor

@chenwhql chenwhql left a comment

Choose a reason for hiding this comment

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

LGTM

@zyfncg zyfncg merged commit 0408701 into PaddlePaddle:develop Mar 25, 2022
@zyfncg zyfncg deleted the scalar_type branch March 25, 2022 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants