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

DirectMLX.h Split fix a tiny bug which caused by variable 'axisSizeSum' set but not used #223

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Libraries/DirectMLX.h
Original file line number Diff line number Diff line change
Expand Up @@ -2322,7 +2322,6 @@ namespace dml
{
TensorDesc inputTensor = input.Impl()->GetOutputDesc();
detail::GraphBuilder* builder = input.Impl()->GetGraphBuilder();
uint32_t axisSizeSum = 0;

std::vector<TensorDesc> outputTensors;
outputTensors.reserve(outputAxisSizes.size());
Expand All @@ -2342,7 +2341,14 @@ namespace dml
axisSizeSum += outputAxisSize;
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't this now fail to compile?

Copy link
Contributor

Choose a reason for hiding this comment

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

Concur, as I see axisSizeSum being used on line 2342.

Copy link
Author

Choose a reason for hiding this comment

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

Issue #220 describes the detailed error log. TheaxisSizeSum used in 2342 only be assignment for the newer clang. The axisSizeSum only be used for assert statement on line 2345.

Copy link
Contributor

Choose a reason for hiding this comment

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

Line 2341 should be deleted now.

}

#if defined(_DEBUG)
Copy link
Contributor

@fdwr fdwr Jun 25, 2022

Choose a reason for hiding this comment

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

#ifndef NDEBUG would be better here, since NDEBUG corresponds for C-style assertions, and _DEBUG is a non-standard macro defined by Visual Studio, but not necessarily other compilers. Also you'll need to delete line 2341.

uint32_t axisSizeSum = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: tab

for (uint32_t outputAxisSize : outputAxisSizes)
{
axisSizeSum += outputAxisSize;
}
assert(axisSizeSum == inputTensor.sizes[axis]);
#endif

DML_SPLIT_OPERATOR_DESC desc = {};
desc.Axis = axis;
Expand Down