onnx-mlir icon indicating copy to clipboard operation
onnx-mlir copied to clipboard

Problem caused by the "name" attribute added to ONNXConstantOp

Open chentong319 opened this issue 3 years ago • 1 comments

The problem is with check-onnx-lit.

In the onnx-to-krnl pass, a name attribute is added to ConstantOp with unique ID, such as "constant_0" and "constant_1". When a test case is added to onnx_lowering.mlir, the assumed common practice is to run the new test case separately and use utils/milr2FileCheck.py to generate the check code. But when the test case is added into onnx_lowering.mlir, the number for the name attribute will change because the counter is globally across all the functions. I found that the check has been modified to name={{.*}} in the onnx_lowering.mlir and that works. I think we have three options:

  1. Generate that name attribute only when asked by an option
  2. update utils/milr2FileCheck.py to avoid manual modification to the check code
  3. Update the document to inform user how to manually change the output of mlir2FileCheck.py

chentong319 avatar Feb 09 '22 19:02 chentong319

As I know, these names will be used to generate global constants in LLVM, so even at this high level we must ensure that they are unique. In that sense, it seems too early to have them at high level. One suggestion is to remove these name attributes and we will automatically generate them when lowering krnl to llvm.

tungld avatar Feb 10 '22 00:02 tungld