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

fix randint op #58295

Merged
merged 9 commits into from
Nov 7, 2023
Merged

fix randint op #58295

merged 9 commits into from
Nov 7, 2023

Conversation

xingmingyyj
Copy link
Contributor

@xingmingyyj xingmingyyj commented Oct 21, 2023

PR types

Others

PR changes

Others

Description

fix randint op

  • 新ir下暂时不对旧ir下定义的RAW类型进行翻译,所以这里对于randint op的out进行特殊处理
  • randint op 的输出值具有随机性,所以这里和exponential op的处理相同,设为NO CHECK

@paddle-bot
Copy link

paddle-bot bot commented Oct 21, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Oct 21, 2023
paddle::framework::proto::VarType::Type var_type =
static_cast<paddle::framework::proto::VarType::Type>(dtype_num);

pir::Type dtype = type_translator.operator[](var_type)(ctx, *var);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pir::Type dtype = type_translator.operator[](var_type)(ctx, *var);
pir::Type dtype = type_translator[var_type](ctx, *var);

这行应该可以这样?

另外,输出类型的翻译过程能否优化为

pir::Type translated_var_type = type_translator[VarType::LOD_TENSOR](ctx, *var);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改为

 pir::Type dtype = type_translator[var_type](ctx, *var);

这里主要是要翻译的LOD_TENSOR的dtype类型会出现RAW类型,直接调用type_translator[VarType::LOD_TENSOR](ctx, *var)的话,会调用对应的函数翻译RAW类型,但是目前不支持RAW类型的翻译,所以这里仿照InferMeta的逻辑,将attribute中的dtype指定给Out

"[op:%s] Output %s should not be null",
op_desc.Type(),
var_name);
int dtype_num = PADDLE_GET_CONST(int, op_desc.GetAttr("dtype"));
Copy link
Contributor

Choose a reason for hiding this comment

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

不建议叫dtype_num。另外dtype是属性,但是VarDesc中也有dtype字段,没有特殊情形用VarDesc里的dtype就可以了吧,不建议在这里做额外的工作。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改dtype_num为dtype_attr_val。如果直接使用VarDesc里的dtype会遇到翻译RAW类型的情况

kangguangli
kangguangli previously approved these changes Oct 31, 2023
Copy link
Contributor

@kangguangli kangguangli left a comment

Choose a reason for hiding this comment

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

LGTM

@kangguangli kangguangli merged commit 91cebb5 into PaddlePaddle:develop Nov 7, 2023
28 checks passed
@xingmingyyj xingmingyyj deleted the fix_randint_op branch November 7, 2023 07:14
jiahy0825 pushed a commit to jiahy0825/Paddle that referenced this pull request Nov 7, 2023
* fix randint op

* Update new_ir_op_test_no_check_list

* fix name

* fix  file name

* fix  file name

* Update pir_op_test_no_check_list
zeroRains pushed a commit to zeroRains/Paddle that referenced this pull request Nov 8, 2023
* fix randint op

* Update new_ir_op_test_no_check_list

* fix name

* fix  file name

* fix  file name

* Update pir_op_test_no_check_list
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
* fix randint op

* Update new_ir_op_test_no_check_list

* fix name

* fix  file name

* fix  file name

* Update pir_op_test_no_check_list
SecretXV pushed a commit to SecretXV/Paddle that referenced this pull request Nov 28, 2023
* fix randint op

* Update new_ir_op_test_no_check_list

* fix name

* fix  file name

* fix  file name

* Update pir_op_test_no_check_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants