Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jerrrrry
infinicore
Commits
2d393626
Commit
2d393626
authored
Nov 18, 2025
by
zhuyue
Committed by
zhuyue
Nov 18, 2025
Browse files
issue/618 - Add __eq__ to device and narrow method to Tensor.
parent
74934cdf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
python/infinicore/device.py
python/infinicore/device.py
+14
-0
python/infinicore/tensor.py
python/infinicore/tensor.py
+3
-0
No files found.
python/infinicore/device.py
View file @
2d393626
...
...
@@ -35,6 +35,20 @@ class device:
def
__str__
(
self
):
return
f
"
{
self
.
type
}{
f
':
{
self
.
index
}
' if self.index is not None else ''
}
"
def
__eq__
(
self
,
other
):
"""
Compare two device objects for equality.
Args:
other: The object to compare with
Returns:
bool: True if both objects are device instances with the same type and index
"""
if
not
isinstance
(
other
,
device
):
return
False
return
self
.
type
==
other
.
type
and
self
.
index
==
other
.
index
@
staticmethod
def
_to_infinicore_device
(
type
,
index
):
all_device_types
=
tuple
(
_infinicore
.
Device
.
Type
.
__members__
.
values
())[:
-
1
]
...
...
python/infinicore/tensor.py
View file @
2d393626
...
...
@@ -96,6 +96,9 @@ class Tensor:
def
__mul__
(
self
,
other
):
return
infinicore
.
mul
(
self
,
other
)
def
narrow
(
self
,
dim
,
start
,
length
):
return
infinicore
.
narrow
(
self
,
dim
,
start
,
length
)
def
empty
(
size
,
*
,
dtype
=
None
,
device
=
None
,
pin_memory
=
False
):
return
Tensor
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment