Commit 1e84d3a4 authored by pengcheng888's avatar pengcheng888
Browse files

issue/850 - 对Tensor和device类不存在的属性访问,则抛出异常

parent c8a11a6a
......@@ -34,7 +34,10 @@ class device:
def __getattr__(self, name):
# Lazily construct and cache an attribute.
# 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)
def __repr__(self):
......
......@@ -42,6 +42,11 @@ class Tensor:
getattr(self._underlying, name)
),
)
else:
raise AttributeError(
"{!r} object has no attribute {!r}".format(__name__, name)
)
return getattr(self, name)
@property
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment