APITest 测试基建:新增 Operator Compare 多实现对比工具#657
Open
cangtianhuang wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
tester/operator_compare复用 PaddleAPITest config、TensorConfig和 Paddle→Torch converter,对指定算子 config 进行 Paddle / Torch / custom 多实现数值对比,并生成结构化结果与报告。使用场景
用于在开发、调试或扩展算子时,对单个或少量 API config 做多实现数值对比、误差分析和报告归档。
功能简介
执行流程
核心能力
APIConfig/TensorConfig构造 Paddle 和 Torch 共用输入。Paddle2TorchConverter将 Paddle API 映射到 Torch 实现。paddle、torch和注册的 custom implementation。results.json、summary.csv、pairwise CSV、report.md和可选图示。开发指南摘要
优先方式:只增加 config
当 Paddle API 能直接执行、Torch reference 已在
mapping.json/rules.py中支持、输出可由通用逻辑转换为torch.Tensor时,只需要增加或复用 config:Torch reference 不存在:补充 converter rule
如果
Paddle2TorchConverter.convert(api_name)不支持目标 API,在tester/paddle_to_torch/mapping.json增加映射;简单映射优先使用GenericRule字段,复杂逻辑在tester/paddle_to_torch/rules.py中增加专用 rule。_C_ops无签名算子:补充参数名绑定部分
_C_ops没有 Python signature,而 converter rule 需要通过命名变量取参数。此时在tester/operator_compare/implementations.py的MANUAL_ARGUMENT_NAMES中补充位置参数名:通用实现无法表达:注册 custom implementation
当
paddle/torch通用路径无法表达某个实验实现时,在tester/operator_compare/implementations.py中注册 custom runner,并通过--implementations paddle,torch,my_impl使用。主要文件
测试指南摘要
新增算子时建议覆盖:
APIConfig正确解析。build_compare_suite()能生成预期 implementation id。_C_ops参数绑定,使用对应_C_opsconfig 做 CLI smoke。本 PR 已通过 CLI smoke 覆盖:
add通用路径。fused_linear_param_grad_add_C_ops参数绑定与真实执行路径。使用示例
单条 config
add smoke
fused_linear_param_grad_add smoke