Commit Graph

2 Commits

Author SHA1 Message Date
Ang Gao 2b30705948
[Feat][NORM_SOFTMAX] Infer shape metadata from inputs (#1690)
## Summary

- infer BatchNorm/GroupNorm/InstanceNorm and Softmax/LogSoftmax
shape/dtype metadata from forward inputs instead of requiring
construction-time `N/C/spatial/dtype` metadata
- lazily specialize and JIT kernels in `forward()` with `_kernel_cache`
as the authoritative specialization cache
- retain `self.kernel` as the last-used kernel handle only, so repeated
calls can overwrite it when dispatching a different specialization while
cache hits avoid rebuild/JIT work
- update tests and benchmarks to use the preferred input-derived API
while keeping explicit constructor metadata as optional compatibility
guards

## Kernel Cache / `self.kernel` Contract

- `__init__` no longer eagerly builds kernels for these ops.
- `forward()` resolves the specialization from runtime tensors, looks
up/builds the cached kernel, and assigns `self.kernel = kernel` for
compatibility/debug visibility.
- `_kernel_cache` owns compiled specializations; `self.kernel` is not
the cache and may change on later calls with different input
shapes/devices/dtypes.
- For an already-JITed specialization, the hot path is metadata
validation + cache key lookup + assignment, without another kernel
build.

## Testing

- `python -m py_compile` on changed op/test/benchmark files
- `python -m ruff check` on changed op/test/benchmark files
- local Docker GPU smoke with
`ghcr.io/tile-ai/tileops-runner:65dbc98-torch2.10` on GPU 4:
  - `87 passed, 12 skipped, 138 deselected, 14 warnings`
- local Docker manifest checks for affected ops:
- `SoftmaxFwdOp`, `LogSoftmaxFwdOp`, `BatchNormFwdOp`, `BatchNormBwdOp`,
`GroupNormFwdOp`, `GroupNormFwdOpNoAffine`, `InstanceNormFwdOp`,
`InstanceNormFwdOpNoAffine`
- all passed; remaining output is existing advisory
`_infer_output_shapes` warnings

Closes #1686
Refs #1674
2026-07-15 15:40:21 +08:00
Cao Ying 0451c058a9
[Chore][Release] merge testbed into main: op-family alignment + new ops (#1380)
## Summary
Merge 27 commits accumulated on `testbed` into `main`. Covers
manifest-spec alignment for the elementwise (unary/binary/multi-input),
reduction, and normalization families; new ops (LerpTensorFwd,
Reciprocal, fused tanh-GELU, InstanceNormFwdOpNoAffine,
GroupNorm/InstanceNorm no-affine variants); shared dispatch/refactor
cleanup; and supporting manifest DSL (`promote_int_to_float`), tests,
and process docs.

## Highlights
- **Family alignment to manifest spec**: elementwise_unary_activation
(#1211), elementwise_binary (#1222), elementwise_multi_input (#1229),
reduction (#1235), normalization (#1240).
- **New ops / variants**: LerpTensorFwd (#1264), Reciprocal +
`promote_int_to_float` DSL (#1252), fused tanh-GELU (#1262),
GroupNorm/InstanceNorm no-affine (#1274, #1284),
InstanceNormFwdOpNoAffine running-stats (#1375).
- **Refactors**: activation shared bases (#1230), dispatch_kernel
routing (#1260, #1368), normalization hotfix cleanup (#1256),
elementwise_binary torch-fallback removal (#1248).
- **Tests / docs**: manifest-driven L1 parity for elementwise_binary
(#1370), drop manifest-mirror tests (#1374), FLIP_STATUS carve-out
(#1258), spec-only -> implemented promotion rule (#1271).

## Test plan
- [ ] CI green on the PR branch
- [ ] \`make test\` passes locally
- [ ] Manifest validator and strict-parity gates pass

---------

Co-authored-by: Ibuki 🍃 — a wind born from GPTs <Ibuki-wind@users.noreply.github.com>
2026-05-09 00:03:37 +08:00