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 test_retinanet_detection_output #59813

Closed
wants to merge 7 commits into from

Conversation

ooooo-create
Copy link
Contributor

PR types

Others

PR changes

Others

Description

PIR Op单测修复
修复单测 test_retinanet_detection_output 否
第一次,不太会,麻烦大佬看看~
@xingmingyyj @kangguangli

1416: ERROR: test_check_output (test_retinanet_detection_output.TestRetinanetDetectionOutOp1)
1416: ----------------------------------------------------------------------
1416: Traceback (most recent call last):
1416:   File "/home/aistudio/Paddle/build/test/legacy_test/test_retinanet_detection_output.py", line 343, in test_check_output
1416:     self.check_output()
1416:   File "/home/aistudio/Paddle/build/test/legacy_test/op_test.py", line 2763, in check_output
1416:     res = self.check_output_with_place(
1416:   File "/home/aistudio/Paddle/build/test/legacy_test/op_test.py", line 2622, in check_output_with_place
1416:     static_checker.check()
1416:   File "/home/aistudio/Paddle/build/test/legacy_test/op_test.py", line 2192, in check
1416:     self.calculate_output()
1416:   File "/home/aistudio/Paddle/build/test/legacy_test/op_test.py", line 2200, in calculate_output
1416:     outs, fetch_list = self.op_test._calc_output(
1416:   File "/home/aistudio/Paddle/build/test/legacy_test/op_test.py", line 1584, in _calc_output
1416:     self._check_ir_output(place, program, feed_map, fetch_list, outs)
1416:   File "/home/aistudio/Paddle/build/test/legacy_test/op_test.py", line 1464, in _check_ir_output
1416:     ir_outs = executor.run(
1416:   File "/home/aistudio/Paddle/build/python/paddle/base/executor.py", line 1733, in run
1416:     res = self._run_impl(
1416:   File "/home/aistudio/Paddle/build/python/paddle/base/executor.py", line 1905, in _run_impl
1416:     program, new_exe = self._executor_cache.get_program_and_executor(
1416:   File "/home/aistudio/Paddle/build/python/paddle/base/executor.py", line 930, in get_program_and_executor
1416:     return self._get_cached_program_and_executor(
1416:   File "/home/aistudio/Paddle/build/python/paddle/base/executor.py", line 1072, in _get_program_and_executor
1416:     new_exe = _StandaloneExecutor(place, plan, scope)
1416:   File "/home/aistudio/Paddle/build/python/paddle/base/executor.py", line 813, in __init__
1416:     self._new_exe = self._create_new_executor()
1416:   File "/home/aistudio/Paddle/build/python/paddle/base/executor.py", line 849, in _create_new_executor
1416:     new_exe = core.StandaloneExecutor(self._place, self._plan, self._scope)
1416: RuntimeError: (PreconditionNotMet) op [pd_op.retinanet_detection_output] kernel output args defs should equal op outputs
1416:   [Hint: Expected op_item->num_results() == output_defs.size(), but received op_item->num_results():1 != output_defs.size():0.] (at /home/aistudio/Paddle/paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc:1286)

修复后打开FLAGS_enable_pir_in_executor单测是否通过:未测试
(多余的修改,是分支切错了,最后会复原)

Copy link

paddle-bot bot commented Dec 7, 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 Dec 7, 2023
@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Dec 8, 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.

op_item->num_results() == output_defs.size(), but received op_item->num_results():1 != output_defs.size():0.

这种bug可能有两个原因,这里是因为算子的kernel通过STRUCT kernel方式注册到phi算子体系中,导致phi kernel的解析有问题。解决方法是在paddle/fluid/pir/dialect/operator/utils/utils.cc的LegacyOpList添加新定义的算子名。

在采取了上面的解决方案后,如果依然报相同错误,那就是另一个原因,选择了错误的kernel key,可以参考comment里提及的interfaces的配置,尝试解决。

@@ -109,6 +109,7 @@ test_elementwise_mul_op
test_elementwise_pow_op
test_erf_op
test_erfinv_op
test_etinanet_detection_output
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
test_etinanet_detection_output
test_retinanet_detection_output

Comment on lines +1423 to +1431
- op: retinanet_detection_output
args: (Tensor[] bboxes, Tensor[] scores, Tensor[] anchors, Tensor iminfo, float score_threshold, int64_t nms_top_k, float nms_threshold, float nms_eta, int64_t keep_top_k)
output: Tensor(out)
infer_meta:
func: RetinanetDetectionOutputInferMeta
param: [bboxes, scores, anchors, iminfo]
kernel:
func: retinanet_detection_output
optional: bboxes, scores, anchors
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
- op: retinanet_detection_output
args: (Tensor[] bboxes, Tensor[] scores, Tensor[] anchors, Tensor iminfo, float score_threshold, int64_t nms_top_k, float nms_threshold, float nms_eta, int64_t keep_top_k)
output: Tensor(out)
infer_meta:
func: RetinanetDetectionOutputInferMeta
param: [bboxes, scores, anchors, iminfo]
kernel:
func: retinanet_detection_output
optional: bboxes, scores, anchors
- op: retinanet_detection_output
args: (Tensor[] bboxes, Tensor[] scores, Tensor[] anchors, Tensor iminfo, float score_threshold, int64_t nms_top_k, float nms_threshold, float nms_eta, int64_t keep_top_k)
output: Tensor(out)
infer_meta:
func: RetinanetDetectionOutputInferMeta
param: [bboxes, scores, anchors, iminfo]
kernel:
func: retinanet_detection_output
data_type : scores
interfaces: RetinanetDetectionOutputOpParseKernelKey

这里有两个问题跟你确认下:

  1. 为什么要添加optional字段呢?我看retinanet_detection_output_op.cc里面对这些输入声明了AsDuplicable,但是并没有声明AsDispensable
  2. interfaces字段的添加,这个是为了迁移原算子体系下RetinanetDetectionOutputOp::GetExpectedKernelType引入的。除了在yaml配置字段,还需要在 paddle/fluid/pir/dialect/operator/interface/interface.cc里定义一个RetinanetDetectionOutputOpParseKernelKey函数,可以参考 [PIR] Add parse kernel key interface #59124 定义的UniqueOpParseKernelKey。

const MetaTensor& iminfo,
MetaTensor* out,
MetaConfig config) {
std::vector<decltype(bboxes[0]->dims())> bboxes_dims;
Copy link
Contributor

Choose a reason for hiding this comment

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

需要先PADDLE_ENFORCE( bboxes.size() > 0),原infershape中的PADDLE_ENFORCE也需要迁移,判断输入输出是否存在的除外。

Copy link

paddle-ci-bot bot commented Dec 29, 2023

Sorry to inform you that 33fb40a's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

@luotao1 luotao1 changed the title 【PIR OpTest Fix No.11】 fix test_retinanet_detection_output fix test_retinanet_detection_output Apr 9, 2024
@luotao1 luotao1 closed this Apr 9, 2024
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants