Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

int8 and uint8 support in Pad and other ops #387

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

igor-yusupov
Copy link
Contributor

No description provided.

@igor-yusupov igor-yusupov changed the title int8 and uint8 support in Pad and other ops WIP: int8 and uint8 support in Pad and other ops Oct 16, 2024
@igor-yusupov igor-yusupov changed the title WIP: int8 and uint8 support in Pad and other ops int8 and uint8 support in Pad and other ops Oct 16, 2024
.DS_Store Outdated
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this macOS-specific .DS_Store file. I suggest creating a global .gitignore for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Sorry, I accidentally pushed that file. I also updated .gitignore file.
I think we need to make squash commit to not have this file in git history

Input::Int8Tensor(t) => Ok(t.map_in(pool, |x| *x as f32).into()),
Input::UInt8Tensor(t) => Ok(t.map_in(pool, |x| *x as f32).into()),
},
DataType::Int8 => match input {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that using as for casts is fine for all cases here. Just making some notes for myself:

Converting non-i8 types to i8 will truncate in various ways, and the same for u8. The Cast op specs are here. The main cases of interest are:

  • Float -> int when out of range: ONNX spec says undefined, so an as cast is fine
  • Int -> Int when out of range: ONNX spec says when OOR, discard higher bits and reinterpret (with respect to two’s complement representation for signed types). For example, 200 (int16) -> -56 (int8).. This matches the behavior of as in Rust

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants