Skip to content

Commit 586fdfb

Browse files
authored
fix MS 2.7.1 caused error (#2230)
1 parent b0f7439 commit 586fdfb

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ bash scripts/build_and_reinstall.sh
141141
| 0.2.x | >=2.1.0 | >=3.8, <=3.9 |
142142
| 0.3.x | >=2.1.0, <=2.3.1 | >=3.8, <=3.9 |
143143
| 0.4.x | >=2.2.x, <=2.5.0 | >=3.9, <=3.11 |
144-
| 0.5.x | >=2.5.0, <=2.7.0. | >=3.10, <=3.11 |
144+
| 0.5.0 | >=2.5.0, <=2.7.0 | >=3.10, <=3.11 |
145+
| 0.6.x | >=2.7.1. | >=3.10, <=3.11 |
145146

146147
## Introduction
147148

mindtorch/_tensor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def __init__(self, *args, **kwargs):
118118
Tensor.__init__ = __init__
119119
origin_setitem = Tensor.__setitem__
120120
origin_is_contiguous = Tensor.is_contiguous
121+
origin_to = Tensor.to
121122
Tensor._requires_grad = False
122123

123124
def tensor(data, *, dtype=None, device=None, requires_grad=False):
@@ -248,6 +249,8 @@ def __getitem__(self, slices):
248249

249250
if self.device.type == 'meta':
250251
out = ops.getitem_np(self, slices)
252+
elif self.device.type == 'cpu':
253+
return ops.getitem(self, slices)
251254
else:
252255
out = ops.tensor_getitem(self, slices)
253256

@@ -2251,7 +2254,7 @@ def _move_to(self, device, non_blocking=False):
22512254
# self.data_sync(True)
22522255
if self.device.type == 'cpu':
22532256
self.data_ptr()
2254-
data = Tensor.move_to(self, device_str, blocking=not non_blocking)
2257+
data = origin_to(self, device_str, non_blocking=non_blocking)
22552258

22562259
out = Tensor(data)
22572260
out._device = device

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def run(self):
170170
},
171171

172172
install_requires=[
173-
'mindspore>=2.5.0',
173+
'mindspore>=2.7.1',
174174
'tqdm',
175175
'requests',
176176
'accelerate>=1.6.0', # hf dependency

0 commit comments

Comments
 (0)