-
Notifications
You must be signed in to change notification settings - Fork 25
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
Avoid dtype comparison failure in take
-- upcast indices in take_strict_sorted
#464
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,7 +104,9 @@ macro_rules! match_each_integer_ptype { | |
PType::U16 => __with__! { u16 }, | ||
PType::U32 => __with__! { u32 }, | ||
PType::U64 => __with__! { u64 }, | ||
_ => panic!("Unsupported ptype {}", $self), | ||
PType::F16 => panic!("Unsupported ptype f16"), | ||
PType::F32 => panic!("Unsupported ptype f32"), | ||
PType::F64 => panic!("Unsupported ptype f64"), | ||
Comment on lines
+107
to
+109
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. was this necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to remove any string concat at compile time There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (So max_value can be a const fn since format! isn't const) |
||
} | ||
}) | ||
} | ||
|
@@ -164,6 +166,10 @@ impl PType { | |
self.byte_width() * 8 | ||
} | ||
|
||
pub const fn max_value(&self) -> usize { | ||
match_each_integer_ptype!(self, |$T| $T::MAX as usize) | ||
} | ||
|
||
pub fn to_signed(self) -> Self { | ||
match self { | ||
Self::U8 => Self::I8, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it's better to assert on it here, b/c you can do subtract_scalar with negative value. let's remove the TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will update comment