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
d9541783
Unverified
Commit
d9541783
authored
Dec 26, 2025
by
pengcheng888
Committed by
GitHub
Dec 26, 2025
Browse files
Merge pull request #858 from pengcheng888/issue/850
issue/850 - Tensor和device类访问不存在的属性,则抛出异常
parents
ed04d3e6
1e84d3a4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletion
+9
-1
python/infinicore/device.py
python/infinicore/device.py
+4
-1
python/infinicore/tensor.py
python/infinicore/tensor.py
+5
-0
No files found.
python/infinicore/device.py
View file @
d9541783
...
@@ -34,7 +34,10 @@ class device:
...
@@ -34,7 +34,10 @@ class device:
def
__getattr__
(
self
,
name
):
def
__getattr__
(
self
,
name
):
# Lazily construct and cache an attribute.
# Lazily construct and cache an attribute.
# such as, self._underlying .
# such as, self._underlying .
setattr
(
self
,
name
,
device
.
_to_infinicore_device
(
self
.
type
,
self
.
index
))
if
name
==
"_underlying"
:
setattr
(
self
,
name
,
device
.
_to_infinicore_device
(
self
.
type
,
self
.
index
))
else
:
raise
AttributeError
(
"{!r} object has no attribute {!r}"
.
format
(
self
,
name
))
return
getattr
(
self
,
name
)
return
getattr
(
self
,
name
)
def
__repr__
(
self
):
def
__repr__
(
self
):
...
...
python/infinicore/tensor.py
View file @
d9541783
...
@@ -42,6 +42,11 @@ class Tensor:
...
@@ -42,6 +42,11 @@ class Tensor:
getattr
(
self
.
_underlying
,
name
)
getattr
(
self
.
_underlying
,
name
)
),
),
)
)
else
:
raise
AttributeError
(
"{!r} object has no attribute {!r}"
.
format
(
__name__
,
name
)
)
return
getattr
(
self
,
name
)
return
getattr
(
self
,
name
)
@
property
@
property
...
...
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