robertknight / rten

ONNX neural network inference engine
124 stars 9 forks source link

int8 and uint8 support in Pad and other ops #387

Closed igor-yusupov closed 1 month ago

igor-yusupov commented 1 month ago

Change description

robertknight commented 1 month ago

Some notes for myself on float-to-int cast compatibility hazards:

The Cast spec says that the behavior of floating point -> integer casts are undefined if out of range. From testing numpy / PyTorch it appears that they have the same behavior as static_cast<int>(some_float) in C++. This behavior can vary depending on the platform and on wasm32 can trap. Rust's as on the other hand guarantees saturation at the cost of a potential performance impact. See https://github.com/rust-lang/rust/issues/67058 and https://github.com/rust-lang/rust/issues/10184.

Saturation seems like it would probably be the most useful failure handling and is cross platform. Sticking with as seems sensible unless performance turns out to be a major issue.

robertknight commented 1 month ago

Note for the changelog: This adds u8 and i8 support to: