webonnx / wonnx

A WebGPU-accelerated ONNX inference run-time written 100% in Rust, ready for native and the web
Other
1.54k stars 54 forks source link

initializer->attribute promotion doesn't respect `raw_data` field #159

Closed SludgePhD closed 1 year ago

SludgePhD commented 1 year ago

Describe the bug ONNX files can store tensor data either in a type-specific field, or in the raw_data field as raw, little-endian bytes.

wonnx promotes constant tensors to node attributes to allow evaluation, but that promotion only looks at the type-specific field, not raw_data, leading it to write an empty tensor in the attribute. This then shows up as an error like:

compiling node 'model_1/model/channel_padding/Pad' failed: the value '[]' is invalid for attribute 'pads' (opset version 13)'

To Reproduce (this requires the optimizer fix from https://github.com/webonnx/wonnx/pull/158 to reproduce)

To reproduce, try running inference for palm_detection_lite.onnx.zip.