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

feat/tensor: implement IntoTensorDesc for [usize; N], N=1...6 #57

Merged
merged 1 commit into from
Mar 21, 2016

Conversation

alexandermorozov
Copy link
Contributor

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.

@hobofan
Copy link
Member

hobofan commented Mar 20, 2016

Thanks, looks a lot nicer to use! I think it is also somewhat related to #49.

Package version is also bumped to make it possible to depend on this feature.

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.
@alexandermorozov
Copy link
Contributor Author

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.

@hobofan
Copy link
Member

hobofan commented Mar 21, 2016

@homu r+

@homu
Copy link
Collaborator

homu commented Mar 21, 2016

📌 Commit 18aa9f1 has been approved by hobofan

@homu homu merged commit 18aa9f1 into autumnai:master Mar 21, 2016
homu added a commit that referenced this pull request Mar 21, 2016
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.
@homu
Copy link
Collaborator

homu commented Mar 21, 2016

⚡ Test exempted - status

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.

3 participants