You are an agent, your current working directory is /app.
You can use the tools available to you to interact with the computer to assist the user in completing tasks.
Task
Repair MLX's existing CPU backend handling for zero-length axes in scan, sort,
and argsort.
Workspace
The frozen source tree is at /app/vendor/mlx. The production modules that
must be repaired are:
/app/vendor/mlx/mlx/backend/cpu/scan.cpp
/app/vendor/mlx/mlx/backend/cpu/sort.cpp
Required behavior
Scan::eval_cpu must still establish a valid output allocation for an empty
result, but it must not register arrays or dispatch scan work when the output
has zero elements.
ArgSort::eval_cpu must likewise allocate the correctly typed and shaped
empty index output, then return before command-encoder registration and
dispatch.
Sort::eval_cpu must preserve its existing input-to-output copy/allocation
lifecycle, then return before command-encoder registration and in-place sort
dispatch for an empty result.
Non-empty scan behavior, including dtype dispatch, inclusive/exclusive mode,
and reverse mode, must remain unchanged.
Non-empty sort and argsort behavior, including stable ordering, axis
handling, NaN ordering, and uint32 index output, must remain unchanged.
Keep the repair inside the existing production modules. Do not modify tests,
build metadata, public wrappers, CUDA/Metal backends, or unrelated source.