autumnai / collenchyma

Extendable HPC-Framework for CUDA, OpenCL and common CPU
http://autumnai.github.io/collenchyma
Apache License 2.0
475 stars 33 forks source link

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

Closed alexandermorozov closed 8 years ago

alexandermorozov commented 8 years ago

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 commented 8 years ago

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.

alexandermorozov commented 8 years ago

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 commented 8 years ago

@homu r+

homu commented 8 years ago

:pushpin: Commit 18aa9f1 has been approved by hobofan

homu commented 8 years ago

:zap: Test exempted - status