Repository navigation
Fix C++ benchmarks failing to build on overloaded astype - #4025
Merged
Merged
Conversation
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
The C++ benchmarks do not compile:
mx::astypehas two overloads (ops.h:51andops.h:52), so the bare name cannot be deduced as the template argument oftime_fn. There are 11 of these acrosssingle_ops.cppandirregular_strides.cpp, and they are the only errors in the target.Wrapped the three argument form in a small lambda per file, which is the same style the rest of these files already use for ops that need adapting, and left the call sites otherwise unchanged.
With that,
MLX_BUILD_BENCHMARKS=ONbuilds all four binaries and they run:Since the benchmarks default to
OFF, this looks like it went unnoticed for a while rather than being a recent regression.Checklist
Put an
xin the boxes that apply.pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes(benchmark sources, so no test; verified by building with benchmarks enabled and running both binaries)
honest note: freshman contributor and Claude Code helps me hunt, but i found this by turning the benchmarks on and building them, read the actual overload resolution error, checked
ops.hto confirm astype really is overloaded, and then reran both binaries to make sure they produce numbers rather than just compiling. built CPU only here, so i have not exercised the Metal paths of these benchmarks.