Skip to content

Commit f40baea

Browse files
authored
fix core.is_complex (#2146)
1 parent 8ebd765 commit f40baea

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

mindnlp/core/_dtype.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
dtype = Type
2323

2424
@property
25-
def is_floating_point(self):
25+
def _is_floating_point(self):
2626
return isinstance(self, (typing.Float, typing.BFloat))
2727

2828
@property
29-
def is_complex(self):
29+
def _is_complex(self):
3030
return isinstance(self, typing.Complex)
3131

32-
Type.is_floating_point = is_floating_point
33-
Type.is_complex = is_complex
32+
Type.is_floating_point = _is_floating_point
33+
Type.is_complex = _is_complex
3434
Type.__str__ = Type.__repr__
3535

3636

mindnlp/core/ops/tensor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ def numel(input):
1616
def as_tensor(data, dtype=None, **kwarg):
1717
return core.tensor(data, dtype=dtype)
1818

19-
__all__ = ['as_tensor', 'is_floating_point', 'is_tensor', 'numel']
19+
def is_complex(input):
20+
return input.dtype.is_complex
21+
22+
__all__ = ['as_tensor', 'is_floating_point', 'is_tensor', 'numel', 'is_complex']

0 commit comments

Comments
 (0)