File tree Expand file tree Collapse file tree 3 files changed +11
-4
lines changed
Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,11 @@ def _copyto(self, target_nd):
9090 check_call (_LIB .TVMArrayCopyFromTo (self .handle , target_nd .handle , None ))
9191 return target_nd
9292
93+ @property
94+ def shape (self ):
95+ """Shape of this array"""
96+ return tuple (self .handle .contents .shape [i ] for i in range (self .handle .contents .ndim ))
97+
9398 def to_dlpack (self ):
9499 """Produce an array from a DLPack Tensor without copying memory
95100
Original file line number Diff line number Diff line change @@ -68,6 +68,11 @@ cdef class NDArrayBase:
6868 def __set__ (self , value ):
6969 self ._set_handle(value)
7070
71+ @property
72+ def shape (self ):
73+ """ Shape of this array"""
74+ return tuple (self .chandle.shape[i] for i in range (self .chandle.ndim))
75+
7176 def __init__ (self , handle , is_view ):
7277 self ._set_handle(handle)
7378 self .c_is_view = is_view
Original file line number Diff line number Diff line change @@ -157,10 +157,6 @@ def from_dlpack(dltensor):
157157
158158class NDArrayBase (_NDArrayBase ):
159159 """A simple Device/CPU Array object in runtime."""
160- @property
161- def shape (self ):
162- """Shape of this array"""
163- return tuple (self .handle .contents .shape [i ] for i in range (self .handle .contents .ndim ))
164160
165161 @property
166162 def dtype (self ):
@@ -240,6 +236,7 @@ def copyfrom(self, source_array):
240236 except :
241237 raise TypeError ('array must be an array_like data,' +
242238 'type %s is not supported' % str (type (source_array )))
239+
243240 t = TVMType (self .dtype )
244241 shape , dtype = self .shape , self .dtype
245242 if t .lanes > 1 :
You can’t perform that action at this time.
0 commit comments