sonots/cumo

[PLAN] Support conversion between Numo::NArray and Cumo::NArray

sonots opened this issue · 1 comments

POLICY: NO MONKEY PATCH to Numo.

Assume numo_a is an Numo::Int32, and cumo_a is Cumo::Int32.

(1)

Cumo::DFloat.cast(a_cumo) #=> Cumo::DFloat
Cumo::DFloat.cast(a_numo) #=> Cumo::DFloat (Note that casting dtype)
a_cumo.cast_to(Cumo::DFloat) #=> Cumo::DFloat
a_cumo.cast_to(Numo::DFloat) #=> Numo::DFloat (Note that casting dtype)

(2)

Cumo::NArray.from_numo(numo_a) #=> Cumo::Int32
Cumo::NArray.to_numo(cumo_a) #=> Numo::Int32
cumo_a.to_numo #=> Numo::Int32 # optional
cumo_a.store(numo_a) # optional

(2) is my design choice because (1) makes confuse us as Numo::DFloat.cast(a_cumo) may work (but, actually not). Also, (1) has to support converting dtypes, and we have to customize cast method which is already existing.

I will implement only from_numo and to_numo class methods first.


references: cupy http://docs-cupy.chainer.org/en/stable/tutorial/basic.html

cupy.asarray(a_cupy) #=> cupy.ndarray
cupy.asarray(a_numpy) #=> cupy.ndarray
cupy.asnumpy(a_cupy) #=> numpy.ndarray

#83 must be resolved to do this. resolved