[FRONTEND] Fix missing attribute access in DependenciesFinder (#1820)

It seems that patch #1773 introduced a bug, since the `lhs` object
doesn't necessarily have a `__name__` attribute.

I'm hitting this if I modify the matmul tutorial
(gflegar/triton@442b00f4d):

```
File "/home/gflegar/triton/python/triton/runtime/jit.py", line 74, in visit_Attribute
  if lhs is None or lhs.__name__ == "triton":
AttributeError: 'Tensor' object has no attribute '__name__'
```

I think the idea of that patch was to remove the need to import triton
by replacing `lhs is triton` with `lhs.__name__ == "triton"`. This patch
should have the same behavior as the original code, but withouth failing
if `lhs` doesn't havea `__name__` attribute.
This commit is contained in:
Goran Flegar
2023-06-22 22:30:25 +02:00
committed by GitHub
parent 53debc0b1e
commit 8d566e4196

View File

@@ -71,7 +71,7 @@ class DependenciesFinder(ast.NodeVisitor):
lhs = self.visit(node.value)
while isinstance(lhs, ast.Attribute):
lhs = self.visit(lhs.value)
if lhs is None or lhs.__name__ == "triton":
if lhs is None or getattr(lhs, "__name__", "") == "triton":
return None
return getattr(lhs, node.attr)