Skip to content

[CPU] Handle singleton reduction axes in Reduce::eval_cpu - #5020

Draft
archidoge0 wants to merge 1 commit into
ml-explore:mainfrom
archidoge0:fix/cpu-reduce-singleton-shapeless
Draft

archidoge0 wants to merge 1 commit into
ml-explore:mainfrom
archidoge0:fix/cpu-reduce-singleton-shapeless

Conversation

@archidoge0

Copy link
Copy Markdown
Contributor
  • ☑️ I understand it is strictly prohibited to use AI to write PR description
  • AI usage disclosure: None.

Fix #5019 and unblock #5010.

Keep align with cuda(

// When all the reduced axes have size 1 at runtime, which can happen with
// shapeless compilation, the reduction is the identity so just cast-copy
// the input to the output.
if (in.size() > 0 && out.size() == in.size()) {
CopyType ctype =
in.flags().contiguous ? CopyType::Vector : CopyType::General;
copy_gpu(in, out, ctype, s);
return;
}
) and metal(
// When all the reduced axes have size 1 at runtime, which can happen with
// shapeless compilation, the reduction is the identity so just cast-copy
// the input to the output.
if (in.size() > 0 && out.size() == in.size()) {
CopyType ctype =
in.flags().contiguous ? CopyType::Vector : CopyType::General;
copy_gpu(in, out, ctype, stream());
return;
}
) side codes:

This branch has not been deployed

No deployments
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.

[BUG] [CPU] mx.compile(shapeless=True): crash in Reduce::eval_cpu when reduced axes have size 1

1 participant