Skip to content

"Data length mismatch for static tensor" error while compile Float16 Reciprocal op on QNN #26993

@zhenchaoni

Description

@zhenchaoni

I used the “ort.ModelCompiler” api to compile a Float16 model which has a Reciprocal op inside it for QNN Execution Provider. The compilation fails and the error log is below.

[E:onnxruntime:, qnn_model_wrapper.cc:167 onnxruntime::qnn::QnnModelWrapper::CreateQnnInputOutputTensors] Data length mismatch for static tensor. node_name: output_0 tensor_name: _divisor. size calculated from shape: 2, tensor.clientBuf.dataSize: 4

possible cause

A possible cause is that ONNX runtime hard codes using 4 bytes (float) while converting Reciprocal to Div. However, the model is float16, so it expects data size as 2.

std::memcpy(divisor_data.data(), &one, sizeof(float));

repro

Reciprocal-FLOAT16.txt is an example model which only has a single Reciprocal node on it. Please rename the file extension from txt to onnx. The compile code on QNN is like below

model_compiler = ort.ModelCompiler(
    sess_options,
    "Reciprocal-FLOAT16.onnx",
)
 model_compiler.compile_to_file(output_path)

Metadata

Metadata

Assignees

No one assigned

    Labels

    ep:QNNissues related to QNN exeution provider

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions