Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix codegen failure #669

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

meenakshiramanathan1
Copy link
Contributor

@meenakshiramanathan1 meenakshiramanathan1 commented Nov 12, 2024

Fix #506
This PR fixes the issue AssertionError: Setting a tensor value of incorrect shape: (1, 256, 16, 2, 16) vs torch.Size([1, 256, 16, 16, 2]), which was caused due to shape Vs eval functions output shape mismatch in stack op.
More precisely, shape function output was wrong because insertion was not being done correctly here.
To ensure proper insertion at the right axis, changes with axis has been made in shape and decompose function of stack op in eltwise_nary file.

After these changes, it was failing with AttributeError: module 'torch' has no attribute 'uint1' during evaluation of cast op , for which uint1 has been mapped to bool dtype.

@@ -1239,6 +1239,8 @@ def populate_cast_args(graph, nid, compiler_cfg):
node = graph["nodes"][nid]
args = []
dtype = node["attrs"]["dtype"][0][0]
if dtype == "uint1":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we use uint1, and have to use bool precisely? Those are the same, but why true/false vs 1/0?

Can we do this in TVM? AFAIK there is the logic that converts dtypes from pytorch to Forge dtypes (and vice verse). It seems like that would be the proper place to do so.

Copy link
Contributor Author

@meenakshiramanathan1 meenakshiramanathan1 Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has been changed that way because uint1 is not supported and it was throwing error AttributeError: module 'torch' has no attribute 'uint1'

I will check it out and let you know about the tvm part.

@dgolubovicTT
Copy link
Contributor

@meenakshiramanathan1 can we please have a proper overview of changes in PR description and how they solve the issue. Also issue contains only repro and the message but fails to explain what is the cause of the issue.

@meenakshiramanathan1
Copy link
Contributor Author

@meenakshiramanathan1 can we please have a proper overview of changes in PR description and how they solve the issue. Also issue contains only repro and the message but fails to explain what is the cause of the issue.

It has been updated now. Please let me know if any other details are required.

Copy link
Contributor

@dgolubovicTT dgolubovicTT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for providing detailed explanation. It really speeds up the review process.

if axis == -1:
output_shape.append(len(ops))
elif axis < 0:
output_shape.insert(axis + 1, len(ops))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we put elif axis < -1 just to be precise. Also can you add just one line of comment why we use + 1 to handle inserting new axis. This is just to help someone that lands in this part of the code and doesn't have the context...

Copy link
Contributor Author

@meenakshiramanathan1 meenakshiramanathan1 Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure @dgolubovicTT , it has been changed now.

if axis == -1:
inp_shape.append(1)
elif axis < 0:
inp_shape.insert(axis + 1, 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants