PaddlePaddle / Paddle2ONNX

ONNX Model Exporter for PaddlePaddle
Apache License 2.0
670 stars 157 forks source link

模型推理报错:Greater OP 的输入参数(bitwise_and_5.tmp_0)的类型'tensor(bool)'无效。 #1281

Closed jiuyuedeyu156 closed 2 weeks ago

jiuyuedeyu156 commented 3 weeks ago

问题描述

模型推理报错:Greater OP 的输入参数(bitwise_and_5.tmp_0)的类型'tensor(bool)'无效。 opset version = 18 onnxruntime version = 1.17 onnx version = 1.16 查阅onnx 1.17 greater-13的文档,发现greater不支持bool类型的输入。 查阅paddle 2.6 greater_than的文档,发现greater_than支持bool的输入。

推理代码:

ort_session = onnxruntime.InferenceSession(onnx_model_path)
# 生成测试数据
n, c, h, w = 1, 3, 128, 128
fake_data = np.full((n, c, h, w), 1, dtype=np.float32)

fake_shape = np.full((1,2), 1, dtype=np.float32)
fake_shape[0, 0] = h
fake_shape[0, 1] = w

fake_scale = np.full((1,2), 1, dtype=np.float32)
# 使用 ONNX 推理引擎执行推理
results = ort_session.run(None, {'im_shape':fake_shape, 'image': fake_data, 'scale_factor':fake_scale })

报错截图

下图是model.pdmodelbitwise_and_5.tmp_0的具体位置

image

下图是model.onnxbitwise_and_5.tmp_0的具体位置

image