Skip to content

v1.1.0 - Improved Broadcasting & Slicing

Latest

Choose a tag to compare

@c2akula c2akula released this 19 Oct 21:45

✨ Feature Release

This release addresses two major limitations from v1.0.0 and enhances core tensor operations.

πŸ”§ Fixed

Broadcasting Gradient Reduction - Fixed incorrect gradient computation when broadcasting occurs in forward pass:

  • add_backward(): Now correctly reduces gradients when shapes differ (e.g., [3,1] + [3,4])
  • mul_backward(): Now correctly reduces gradients when shapes differ (e.g., [3,1] * [3,4])
  • matmul_backward(): Fixed two critical bugs:
    • Transpose now only swaps matrix dimensions (last 2), not batch dimensions
    • Added gradient reduction for batch broadcasting (e.g., [1,3,4] @ [2,4,5])
  • Added reduce_grad_for_broadcast() helper function

⭐ Added

Enhanced Slice Functionality - Full NumPy-compatible slicing with reverse support:

  • tofu_tensor_arange(): Now supports negative steps for reverse slicing
  • tofu_tensor_rearange(): Now supports negative steps for reverse slicing
  • Examples:
    • arange(10, 0, -1) β†’ [10, 9, 8, ..., 1] βœ…
    • arange(5, 5, 1) β†’ NULL (empty range) βœ…
    • arange(0, 10, -1) β†’ NULL (incompatible step) βœ…

Comprehensive Test Suites:

  • test/standalone/test_broadcast_gradient.c: 5 broadcast gradient tests
  • test/standalone/test_arange_enhanced.c: 6 test categories with 18+ tests

πŸ“Š Testing

  • βœ… All 66 unit tests pass
  • βœ… Phase 1 validation (gradient correctness)
  • βœ… Phase 2 validation (architecture)
  • βœ… Phase 3 validation (classification & regression)
  • βœ… 23+ new tests for enhanced functionality

πŸš€ Performance

  • No performance regressions
  • Minimal overhead for gradient reduction (only when broadcasting occurs)

πŸ“š Documentation

  • Updated README with v1.1.0 announcement
  • Enhanced mdBook user guide with reverse slicing examples
  • Updated Doxygen API comments for arange/rearange functions
  • Comprehensive CHANGELOG entry

πŸ”— Links


Upgrade Note: This release is fully backward compatible with v1.0.0. No breaking changes.