dlexplorer opened a new issue #7096:
URL: https://github.com/apache/tvm/issues/7096


   Many frameworks define dynamism in the shape as -1 in the certain axis while 
TVM has its own constant for this - relay.Any().
   If I take onnx bert model and try to convert like below snippet code, TVM 
will crash.
   Two issues
   1. not crash
   2. During conversion need to identify -1 in the shape and warn that TVM uses 
its own id for defining of dynamic shape/stop execution
   
   Probably stopping of execution after determination of -1 will solve the 
crash as well
   
   snippet:
   ```
   import argparse
   import sys
   import onnx
   import tvm
   from tvm import relay
   
   parser = argparse.ArgumentParser(description=
       "Converts and compiles ONNX model")
   required = parser.add_argument_group('required arguments')
   required.add_argument('-m', '--input_model', required=True, type=str, 
help="path to ONNX model")
   args = parser.parse_args()
   
   onnx_model = onnx.load(args.input_model)
   shape_dict = {}
   shape_dict["input_mask:0"] = [-1,256]
   shape_dict["segment_ids:0"] = [-1,256]
   shape_dict["input_ids:0"] = [-1,256]
   shape_dict["unique_ids_raw_output___9:0"] = [-1,256]
   
   mod, params = relay.frontend.from_onnx(onnx_model, shape_dict)
   
   target = "llvm"
   
   with tvm.transform.PassContext(opt_level=3):
       lib = relay.build(mod, target=target, target_host=target, params=params)
   
   lib.export_library(args.input_model + ".so")                                 
                          
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to