tch-rs
tch-rs copied to clipboard
Revise TryFrom impls and make ndarray optional
TryFrom now receives a referenced type instead of owned type. The move is unnecessary because it always copies the data.
TryInto impls are removed in flavor of TryFrom. That's because TryFrom implies TryInto, but it does not in vice versa.
The ndarray crate becomes an optional but enabled by default feature to avoid bloating. It helps reducing compiling time for those who does not need this feature.
BTW, I noticed the inconsistency of TryFrom<Vec<T>> and From<&[T]>. The latter does not follow the guideline that From<_> should not fail.
Also. regarding to #281, we have lots of From<T> for Tensor that could panic. However, moving to TryFrom is a breaking change. How do you think @LaurentMazare?
I rebase the patch and upgrade ndarray to 0.14. To recap, the PR made following changes:
- Replace
TryIntotoTryFromas suggested by std doc ndarraybecomes an optional but enabled by default cargo feature, to reduce bloating- Update to 0.14
The only breaking change is ndarray version update to 0.14.