增加算子库基准清单结构化输出#32
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the benchmark script to allow listing supported operators even when the 'nvbench' library is not installed, and introduces a new --list-json command-line argument to output the operator list in JSON format. The review feedback suggests directing the runtime error message to sys.stderr instead of sys.stdout to prevent interfering with JSON parsing, and updating the help text of the --op argument to mention --list-json as an alternative to --list.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| sys.exit(1) | ||
|
|
||
| if bench is None: | ||
| print("[ERROR] Runtime environment missing 'nvbench'. Please check configuration.") |
There was a problem hiding this comment.
在命令行工具中,错误信息应当输出到标准错误流(sys.stderr)而不是标准输出流(sys.stdout)。特别是当用户使用 --list-json 等结构化输出功能时,将错误信息输出到标准输出可能会干扰下游脚本对 JSON 的解析。建议将此处的错误打印重定向到 sys.stderr。
| print("[ERROR] Runtime environment missing 'nvbench'. Please check configuration.") | |
| print("[ERROR] Runtime environment missing 'nvbench'. Please check configuration.", file=sys.stderr) |
| parser = argparse.ArgumentParser(description="MCOPLIB Operator Performance Benchmark") | ||
| parser.add_argument("--op", type=str, default=None, help="Operator name (Required, unless --list is used)") | ||
| parser.add_argument("--list", action="store_true", help="List all supported operators and exit") | ||
| parser.add_argument("--list-json", action="store_true", help="Print supported operators as JSON and exit") |
这次改动补上了算子库基准清单结构化输出,主要是为了解决算子库构建和诊断流程里相关信息不够集中、人工整理成本较高的问题,让日常排查、验证和结果归档更直接。
实现上补充了对应工具或脚本逻辑,同时尽量保持现有用法不变,避免影响已有流程。
这一分支已经在沐曦算力环境完成实际验证,相关检查均已通过,现提交合入。