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
8f828d69
Unverified
Commit
8f828d69
authored
Nov 18, 2025
by
PanZezhong1725
Committed by
GitHub
Nov 18, 2025
Browse files
Merge pull request #619 from gongchensu/feature/tensor-narrow-eq
issue/618 - Add __eq__ to device and narrow method to Tensor.
parents
74934cdf
2d393626
Changes
2
Hide 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 @
8f828d69
...
@@ -35,6 +35,20 @@ class device:
...
@@ -35,6 +35,20 @@ class device:
def
__str__
(
self
):
def
__str__
(
self
):
return
f
"
{
self
.
type
}{
f
':
{
self
.
index
}
' if self.index is not None else ''
}
"
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
@
staticmethod
def
_to_infinicore_device
(
type
,
index
):
def
_to_infinicore_device
(
type
,
index
):
all_device_types
=
tuple
(
_infinicore
.
Device
.
Type
.
__members__
.
values
())[:
-
1
]
all_device_types
=
tuple
(
_infinicore
.
Device
.
Type
.
__members__
.
values
())[:
-
1
]
...
...
python/infinicore/tensor.py
View file @
8f828d69
...
@@ -96,6 +96,9 @@ class Tensor:
...
@@ -96,6 +96,9 @@ class Tensor:
def
__mul__
(
self
,
other
):
def
__mul__
(
self
,
other
):
return
infinicore
.
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
):
def
empty
(
size
,
*
,
dtype
=
None
,
device
=
None
,
pin_memory
=
False
):
return
Tensor
(
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