Skip to content

Commit f050e42

Browse files
authored
fix bugs for ms2.5 (#1991)
1 parent 2a09101 commit f050e42

File tree

8 files changed

+533
-408
lines changed

8 files changed

+533
-408
lines changed

mindnlp/core/ops/creation.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,18 @@ def ones_like(input, *, dtype=None):
8181

8282
# arange
8383
has_arange = hasattr(mindspore.mint, 'arange')
84+
range_op = ops.Range()
8485
def arange(start=0, end=None, step=1, *, dtype=None):
86+
if dtype is None:
87+
dtype = mindspore.int64
8588
if ON_ORANGE_PI and dtype in (None, mindspore.int64):
8689
dtype = mindspore.int32
8790
if use_pyboost() and has_arange:
8891
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)
9096

9197
# range
9298
def range(start=0, end=None, step=1, dtype=None):
@@ -125,7 +131,7 @@ def empty(*size, dtype=None, device=None):
125131
if dtype is None:
126132
dtype = get_default_dtype()
127133
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()
129135
else:
130136
out = CTensor(dtype=dtype, shape=size)
131137
return mindspore.Tensor(out)

0 commit comments

Comments
 (0)