ValueError: Cannot use and / or / not operator to Expr, hint: use tvm.tir.all / tvm.tir.any instead

Hi All, I’m trained a RandomForestClassifier on an image dataset and converted it to an ONNX model. Then I tried to optimize the ONNX model with TVM, using the cat image code as the input from this TVM example: Compile ONNX Models.
Unfortunately, getting this ValueError: ValueError: Cannot use and / or / not operator to Expr, hint: use tvm.tir.all / tvm.tir.any instead. Seems like whatever operator the model is using isn’t supported by tvm? However, I don’t exactly have control of swapping it to tvm.tir.all?

from PIL import Image
onnx_model = mlflow.onnx.load_model("0/deeb1d8e10a548f5846b9751eaf60c7c/artifacts/onnx_model")
ml_model = mlflow.onnx.Model.load("0/deeb1d8e10a548f5846b9751eaf60c7c/artifacts/onnx_model")
img_url = "https://github.com/dmlc/mxnet.js/blob/main/data/cat.png?raw=true"
img_path = download_testdata(img_url, "cat.png", module="data")
img = Image.open(img_path).resize((224, 224))
img_ycbcr = img.convert("YCbCr")  # convert to YCbCr
img_y, img_cb, img_cr = img_ycbcr.split()
x = np.array(img_y)[np.newaxis, np.newaxis, :, :]
input_shape = x.shape

# Code below is from TVM ONNX example in their official docs 
# https://tvm.apache.org/docs/how_to/compile_models/from_onnx.html#compile-the-model-with-relay
target = "llvm"
input_name = "input_0"
shape_dict = {input_name: input_shape}

mod, params = relay.frontend.from_onnx(onnx_model, shape_dict, dtype='float64')
# print(mod)
# print(params)
device = tvm.cuda()
print(dir(device))
# Gets stuck in create_executor
with tvm.transform.PassContext(opt_level=1):
    executor = relay.build_module.create_executor(
        "graph", mod, tvm.cpu(0), target, params
    )
    print("line 32 yee")
    executor.evaluate()
print("line 34")
dtype = "float64"
tvm_output = executor(tvm.nd.array(x.astype(dtype))).numpy()
1 Like

Might be an onnx frontend issue for some operators. You can find that op in the error stack trace