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 stack op sanity failure #606

Closed
wants to merge 1 commit into from

Conversation

meenakshiramanathan1
Copy link
Contributor

@meenakshiramanathan1 meenakshiramanathan1 commented Nov 4, 2024

Fix for #506

  1. Axis has been changed in eltwise_nary.py to address AssertionError: Setting a tensor value of incorrect shape: (1, 256, 16, 2, 16) vs torch.Size([1, 256, 16, 16, 2]) #506 for codegen model
  2. Stack op test case was failing with error Trying to access element outside of dimensions: 4 for test cases with dim =-2 and dim =3 in optmised graph pass. It was failing because new_dim was not calculated correctly in can_commute_reshape_through_dim in commute_utils.cpp, hence it was going out of bounds, so a condition was added to skip the out of bounds test case.
    Full log: stack_sanity.log

forge/csrc/passes/commute_utils.cpp Outdated Show resolved Hide resolved
@@ -246,11 +246,12 @@ def decompose(type, attr, dc, inputs):
new_inputs = []
for inp in inputs:
inp_shape = inp.shape.as_list()
inp_shape.insert(axis, 1)
new_inp = dc.op("reshape", [inp], (*inp_shape,))
insertion_index = axis if axis >= 0 else len(inp_shape) + axis + 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to convert to positive indexing?

Copy link
Contributor Author

@meenakshiramanathan1 meenakshiramanathan1 Nov 4, 2024

Choose a reason for hiding this comment

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

With negative axis, insertion is not applied correctly
When axis = -4, output shape is (2, 1, 256, 24, 24) while expected shape from eval function is (1, 2, 256, 24, 24), this is being rectified when axis is being converted to positive

Copy link
Contributor

@nvukobratTT nvukobratTT Nov 5, 2024

Choose a reason for hiding this comment

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

Can we check it in a bit more detail and see why the negative axis isn't supported? From the FFE perspective, we should support both of them.

Edit:
I see the rest of the details here: #615

def test_stack(params):
_, _, dim = params[0][0], params[0][1], params[1]
if dim == -3 or dim == 1:
pytest.xfail("Tensor rank is not 4")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this failing on the FFE side?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is failing in run_mlir_compiler stage
log: stack_mlir.log

// check whether volume above and below matching dim is the same
if ((volume_above(input_shape_vec, i) == volume_above(output_shape_vec, dim)) and
(volume_below(input_shape_vec, i) == volume_below(output_shape_vec, dim)))
(volume_below(input_shape_vec, i) == volume_below(output_shape_vec, dim)) and
(i < output_shape_vec.size()))
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this check prevent from happening?

@dgolubovicTT
Copy link
Contributor

@meenakshiramanathan1 It is not clear to me what is the problem we are solving in second point of the PR, and how we are solving it. Is this a workaround to skip out of bounds test case, or is it general fix? Can you please reference/open the issue and explain what is happening?

@meenakshiramanathan1
Copy link
Contributor Author

@meenakshiramanathan1 It is not clear to me what is the problem we are solving in second point of the PR, and how we are solving it. Is this a workaround to skip out of bounds test case, or is it general fix? Can you please reference/open the issue and explain what is happening?

Please refer to #615

@nvukobratTT
Copy link
Contributor

Let's discuss this one on today's sync. I still have few unknowns that I don't fully grasp at the moment

@meenakshiramanathan1
Copy link
Contributor Author

Opened a new PR #669 related to this

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

Successfully merging this pull request may close these issues.

3 participants