Skip to content

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

Merged
homu merged 1 commit into
autumnai:masterfrom
alexandermorozov:feat-into-tensor-desc
Mar 21, 2016
Merged

feat/tensor: implement IntoTensorDesc for [usize; N], N=1...6#57
homu merged 1 commit into
autumnai:masterfrom
alexandermorozov:feat-into-tensor-desc

Conversation

@alexandermorozov
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

hobofan commented Mar 21, 2016

@homu r+

@homu
Copy link
Copy Markdown
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
Copy Markdown
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