Skip to content

feat: Generalize operator extraction script for unit testing​ #257

Open
Zane-Jiang wants to merge 3 commits intosophgo:masterfrom
Zane-Jiang:future/extract_op
Open

feat: Generalize operator extraction script for unit testing​ #257
Zane-Jiang wants to merge 3 commits intosophgo:masterfrom
Zane-Jiang:future/extract_op

Conversation

@Zane-Jiang
Copy link
Copy Markdown

@Zane-Jiang Zane-Jiang commented Dec 25, 2025

What this pr do?

Fix issue #238

  • Implement onnx/torch operator extraction in extract_op.py, used to extract operator case shapes and parameters from MLIR files into a JSON file.

  • Add options --json_file and --case_id to test_onnx.py to load JSON files as test case inputs for operator testing.

  • Only a subset of basic and commonly used operators is supported.

Usage:

1.extract

extract_op.py  --framework {onnx,torch} --op {Abs,Add,Sub,Mul,Div,AddConst,And,Relu,Concat,Compare,Softmax}
                     mlir_file output_json
#eg
extract_op.py onnx_test_bm1684x/Add/Add.mlir op_add.json  --framework=onnx --op=Add

2.test

test_onnx.py --json_file=xxx --case_id=0 --case=xxx
#eg
test_onnx.py --json_file=op_add.json  --case_id=0 --case=Add

- Implement onnx/torch operator extraction in extract_op.py, used to extract operator case shapes and parameters from MLIR files into a JSON file.

- Add options `--json_file` and `--case_id` to test_onnx.py to load JSON files as test case inputs for operator testing.

- Only a subset of basic and commonly used operators is supported.
- Remove reduant quotation marks during type convert
@xujm1998
Copy link
Copy Markdown

xujm1998 commented Dec 30, 2025

感谢您的工作,
目前实现了功能和几个简单算子,请@charlesxzb 看下能否合入。
考虑前端算子众多,
建议后续基于topops.td的信息用正则化的方式提取MLIR算子,而不是手动添加。

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.

2 participants