- Notifications
You must be signed in to change notification settings - Fork 110
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Describe what you are looking for
##Summary
Reductions like Tensor.sum and nk.sum only accept axis=None (global) or a single int. There is no NumPy-style axis=(0, 1, …) for collapsing several dimensions in one call.
Current behavior
- Stubs:
axis: Optional[int]only (numkong/__init__.pyi—Tensor.sum, nk.sum). - Runtime: non-int
axisraises, e.g.TypeError: an integer is required.
Motivation
For arrays shaped like (H, W, C) or (N, H, W, C), per-channel sums require reducing all spatial axes while keeping the channel axis. In NumPy that is one reduction, e.g. np.sum(x, axis=tuple(range(x.ndim - 1))). With NumKong, callers must chain several sum(axis=…) calls (and handle keepdims carefully) or reshape, which is awkward and error-prone.
Request
Either:
- Extend axis to int | tuple[int, ...] | None with NumPy-compatible semantics (and
keepdims), at least forsum, or - Add a documented, first-class API for “sum over all axes except last” / multi-axis reductions if a tuple
axisis intentionally out of scope.
import numpy as np import numkong as nk t = nk.Tensor(np.ones((2, 3, 4), dtype=np.float32)) t.sum(axis=(0, 1)) # TypeError: an integer is requiredCan you contribute to the implementation?
- I can contribute
Is your feature request specific to a certain interface?
It applies to everything
Contact Details
No response
Is there an existing issue for this?
- I have searched the existing issues
Code of Conduct
- I agree to follow this project's Code of Conduct
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request