feat/tensor: implement IntoTensorDesc for [usize; N], N=1...6#57
Conversation
|
Thanks, looks a lot nicer to use! I think it is also somewhat related to #49.
I am not sure what you mean by this. We do the version bump when cutting a new release, together with the changelog etc.. Could you please amend the commit to remove the version bump? Apart from that it looks good to merge. |
Currently dimensions of a tensor can be specified with usize, tuples, Vecs and slices: SharedTensor::new(backend, &10) SharedTensor::new(backend, &(10, 2)) SharedTensor::new(backend, &vec![10, 2]) In cases like this, vec! causes an unneeded allocation and is a bit more verbose than possible. Usize/tuple syntax looks somewhat irregular. It would be nice to be able to express tensor creation like this: SharedTensor::new(backend, &[10, 2]) But Rust doesn't autocoerce &[usize; _] into &[usize]. This patch adds explicit implementations to make this use case work. Package version is also bumped to make it possible to depend on this feature.
127f20c to
18aa9f1
Compare
|
Oh, I see. I've removed change to package version. Sorry I haven't been clear, a bit later I created PR autumnai/leaf#86 that depends on this feature. It'll have to wait until next collenchyma release. Or it's possible in meantime to use there collenchyma's git master instead of package version, if that's acceptable. I'll look into #49. |
|
@homu r+ |
|
📌 Commit 18aa9f1 has been approved by |
feat/tensor: implement IntoTensorDesc for [usize; N], N=1...6
Currently dimensions of a tensor can be specified with usize, tuples, Vecs
and slices:
SharedTensor::new(backend, &10)
SharedTensor::new(backend, &(10, 2))
SharedTensor::new(backend, &vec![10, 2])
In cases like this, vec! causes an unneeded allocation and is a bit more
verbose than possible. Usize/tuple syntax looks somewhat irregular. It would
be nice to be able to express tensor creation like this:
SharedTensor::new(backend, &[10, 2])
But Rust doesn't autocoerce `&[usize; _]` into `&[usize]`. This patch adds explicit
implementations to make this use case work.
Package version is also bumped to make it possible to depend on this feature.
|
⚡ Test exempted - status |
Currently dimensions of a tensor can be specified with usize, tuples, Vecs
and slices:
In cases like this, vec! causes an unneeded allocation and is a bit more
verbose than possible. Usize/tuple syntax looks somewhat irregular. It would
be nice to be able to express tensor creation like this:
But Rust doesn't autocoerce
&[usize; _]into&[usize]. This patch adds explicitimplementations to make this use case work.
Package version is also bumped to make it possible to depend on this feature.