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

Updated reduceDims for NHWC and NCHW format for forward inference CK #3227

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

@xinlipn xinlipn self-assigned this Sep 3, 2024
@xinlipn xinlipn requested review from JehandadKhan and removed request for JehandadKhan September 3, 2024 02:06
@xinlipn xinlipn marked this pull request as draft September 3, 2024 02:06
@bghimireamd
Copy link
Contributor

@xinlipn Can we also add gtest for NCHW similar to NHWC

@xinlipn
Copy link
Contributor Author

xinlipn commented Sep 3, 2024

@xinlipn Can we also add gtest for NCHW similar to NHWC

@bghimireamd Updated gTest. But one test failed on MI200.

test_bn_infer.log

@xinlipn xinlipn requested review from qianfengz and removed request for amberhassaan September 5, 2024 15:51
Comment on lines +197 to +210
bool IsLayoutNCHW() const
{
if(direction == Direction::Backward)
{
return xDesc.GetLengths().size() == 4
? ((in_layout == "NCHW") && (out_layout == "NCHW") && (din_layout == "NCHW"))
: ((in_layout == "NCDHW") && (out_layout == "NCDHW") &&
(din_layout == "NCDHW"));
}

return xDesc.GetLengths().size() == 4 ? ((in_layout == "NCHW") && (out_layout == "NCHW"))
: ((in_layout == "NCDHW") && (out_layout == "NCDHW"));
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Does it support strides? Because it is possible to set NCHW layout with strides something like 192 1 32 4 instead of 192 48 8 1 for NCHW tensor 2 4 6 8. In that case it will be actually NHWC.
I'm just saying that "layout" does not guarantee actual layout.
Or NHWC tensor of sizes 2 6 8 4 may have strides 192 8 1 48 which is actually NCHW and can be compatible with the algorithm.

Copy link
Contributor

Choose a reason for hiding this comment

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

@CAHEK7 do you think we should also check strides to determine the layout? In conv they just check string

Copy link
Contributor

@BrianHarrisonAMD BrianHarrisonAMD Sep 11, 2024

Choose a reason for hiding this comment

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

I thought it was safe to assume that the layout string would be set to match what the strides are representing.
I remember something similar came up with trying to figure out how to map strides to tensor layout with the graphAPI, and the SetStrides method would either calculate strides from a layout, or set the layout from provided strides.

If the above is true, then I think the way it's done here, and the way it's done for conv is alright. If it's not true, then I am not sure what the purpose of the layout string is since we would need to always check the strides to know what layout it is, and the string should be ignored.

@xinlipn xinlipn changed the title Updated reduceDims for NHWC and NCHW format Updated reduceDims for NHWC and NCHW format for forward inference CK Sep 19, 2024
@xinlipn xinlipn marked this pull request as ready for review September 25, 2024 06:46
@junliume
Copy link
Collaborator

@xinlipn please help watch the CI and progress of the PR. Thanks!

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.

5 participants