@@ -81,12 +81,18 @@ def ones_like(input, *, dtype=None):
81
81
82
82
# arange
83
83
has_arange = hasattr (mindspore .mint , 'arange' )
84
+ range_op = ops .Range ()
84
85
def arange (start = 0 , end = None , step = 1 , * , dtype = None ):
86
+ if dtype is None :
87
+ dtype = mindspore .int64
85
88
if ON_ORANGE_PI and dtype in (None , mindspore .int64 ):
86
89
dtype = mindspore .int32
87
90
if use_pyboost () and has_arange :
88
91
return mindspore .mint .arange (start , end , step , dtype = dtype )
89
- return ops .arange (start , end , step , dtype = dtype )
92
+ if end is None :
93
+ end = start
94
+ start = 0
95
+ return range_op (start , end , step ).astype (dtype )
90
96
91
97
# range
92
98
def range (start = 0 , end = None , step = 1 , dtype = None ):
@@ -125,7 +131,7 @@ def empty(*size, dtype=None, device=None):
125
131
if dtype is None :
126
132
dtype = get_default_dtype ()
127
133
if has_empty :
128
- out = mindspore ._c_expression .pyboost_empty ([size , dtype , device ])
134
+ out = mindspore ._c_expression .pyboost_empty ([size , dtype , device ]). get_value ()
129
135
else :
130
136
out = CTensor (dtype = dtype , shape = size )
131
137
return mindspore .Tensor (out )
0 commit comments