[Mlir-commits] [mlir] Adding mlir models (PR #141158)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue May 27 12:01:23 PDT 2025


================

----------------
Jaddyen wrote:

I'm unable to pass these tests. I suspect I'm failing to correctly pass instructions to line 8 and 32 of the `.mlir` file. Could use some guidance on this.

The first gives the error:
```
Command Output (stdout):
--
# RUN: at line 1
/work/llvm-project/build/bin/mlir-translate --mlir-to-cpp --emit-class=true --class-name=MyAdder --field-name-attribute=tf_saved_model.index_path /tmp/model_emitc.mlir | /work/llvm-project/build/bin/FileCheck /work/llvm-project/mlir/test/mlir-translate/emit-class.mlir --check-prefix=ADDER_TEST
# executed command: /work/llvm-project/build/bin/mlir-translate --mlir-to-cpp --emit-class=true --class-name=MyAdder --field-name-attribute=tf_saved_model.index_path /tmp/model_emitc.mlir
# executed command: /work/llvm-project/build/bin/FileCheck /work/llvm-project/mlir/test/mlir-translate/emit-class.mlir --check-prefix=ADDER_TEST
# .---command stderr------------
# | /work/llvm-project/mlir/test/mlir-translate/emit-class.mlir:8:21: error: ADDER_TEST-NEXT: expected string not found in input
# | // ADDER_TEST-NEXT: std::map<std::string, char*> _buffer_map {{ "another_feature", reinterpret_cast<char*>(v1) },{ "some_feature", reinterpret_cast<char*>(v2) },{ "output_0", reinterpret_cast<char*>(v3) }};
# |                     ^
# | <stdin>:5:14: note: scanning from here
# |  float v3[1];
# |              ^
# | <stdin>:6:2: note: possible intended match here
# |  std::map<std::string, char*> _buffer_map {{ "another_feature", reinterpret_cast<char*>(v1) },{ "some_feature", reinterpret_cast<char*>(v2) },{ "output_0", reinterpret_cast<char*>(v3) }};char* getBufferForName(const std::string& name) const {
# |  ^
# | 
# | Input file: <stdin>
# | Check file: /work/llvm-project/mlir/test/mlir-translate/emit-class.mlir
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |           1: class MyAdder final { 
# |           2: public:  
# |           3:  float v1[1]; 
# |           4:  float v2[1]; 
# |           5:  float v3[1]; 
# | next:8'0                  X error: no match found
# |           6:  std::map<std::string, char*> _buffer_map {{ "another_feature", reinterpret_cast<char*>(v1) },{ "some_feature", reinterpret_cast<char*>(v2) },{ "output_0", reinterpret_cast<char*>(v3) }};char* getBufferForName(const std::string& name) const { 
# | next:8'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | next:8'1      ?                                                                                                                                                                                                                                                  possible intended match
# |           7:  auto it = _buffer_map.find(name); 
# | next:8'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |           8:  return (it == _buffer_map.end()) ? nullptr : it->second; 
# | next:8'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |           9:  } 
# | next:8'0     ~~~
# |          10:  
# | next:8'0     ~
# |          11:  void main() {  
# | next:8'0     ~~~~~~~~~~~~~~~~
# |           .
# |           .
# |           .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--
```

The second test gives the error: 
```
Command Output (stdout):
--
# RUN: at line 1
/work/llvm-project/build/bin/mlir-translate --mlir-to-cpp --emit-class=true --class-name=MyMultiOutput --field-name-attribute=tf_saved_model.index_path /tmp/model_multi_out_emitc.mlir | /work/llvm-project/build/bin/FileCheck /work/llvm-project/mlir/test/mlir-translate/emit-class.mlir --check-prefix=MULTI_OUT
# executed command: /work/llvm-project/build/bin/mlir-translate --mlir-to-cpp --emit-class=true --class-name=MyMultiOutput --field-name-attribute=tf_saved_model.index_path /tmp/model_multi_out_emitc.mlir
# executed command: /work/llvm-project/build/bin/FileCheck /work/llvm-project/mlir/test/mlir-translate/emit-class.mlir --check-prefix=MULTI_OUT
# .---command stderr------------
# | /work/llvm-project/mlir/test/mlir-translate/emit-class.mlir:9:15: error: MULTI_OUT: expected string not found in input
# | // MULTI_OUT: std::map<std::string, char*> _buffer_map {{ "b", reinterpret_cast<char*>(v1) },{ "a", reinterpret_cast<char*>(v2) },{ "output_1", reinterpret_cast<char*>(v3) },{ "output_0", reinterpret_cast<char*>(v4) }};
# |               ^
# | <stdin>:6:14: note: scanning from here
# |  float v4[1];
# |              ^
# | <stdin>:7:2: note: possible intended match here
# |  std::map<std::string, char*> _buffer_map {{ "b", reinterpret_cast<char*>(v1) },{ "a", reinterpret_cast<char*>(v2) },{ "output_1", reinterpret_cast<char*>(v3) },{ "output_0", reinterpret_cast<char*>(v4) }};char* getBufferForName(const std::string& name) const {
# |  ^
# | 
# | Input file: <stdin>
# | Check file: /work/llvm-project/mlir/test/mlir-translate/emit-class.mlir
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |            1: class MyMultiOutput final { 
# |            2: public:  
# |            3:  float v1[1]; 
# |            4:  float v2[1]; 
# |            5:  float v3[1]; 
# |            6:  float v4[1]; 
# | check:9'0                  X error: no match found
# |            7:  std::map<std::string, char*> _buffer_map {{ "b", reinterpret_cast<char*>(v1) },{ "a", reinterpret_cast<char*>(v2) },{ "output_1", reinterpret_cast<char*>(v3) },{ "output_0", reinterpret_cast<char*>(v4) }};char* getBufferForName(const std::string& name) const { 
# | check:9'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | check:9'1      ?                                                                                                                                                                                                                                                                     possible intended match
# |            8:  auto it = _buffer_map.find(name); 
# | check:9'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            9:  return (it == _buffer_map.end()) ? nullptr : it->second; 
# | check:9'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |           10:  } 
# | check:9'0     ~~~
# |           11:  
# | check:9'0     ~
# |           12:  void main() {  
# | check:9'0     ~~~~~~~~~~~~~~~~
# |            .
# |            .
# |            .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--
```


https://github.com/llvm/llvm-project/pull/141158


More information about the Mlir-commits mailing list