Skip to content

Implement and test tensor math operations #2

Description

@code-tc

Summary

Implement and validate `fensor` math-operation traits so non-transactional tensor math reaches v1 parity targets (subject to documented sparse/layout support boundaries and structured unsupported errors).

Scope

  • Implement/complete:
    • `TensorUnary` (`exp`, `ln`, `round`)
    • `TensorMath` (`add`, `sub`, `mul`, `div`, `log`, `pow`, `rem`)
    • `TensorMathScalar` (`*_scalar`)
    • `TensorReduce` (`max`, `min`, `product`, `sum`)
    • `TensorReduceAll` (`max_all`, `min_all`, `product_all`, `sum_all`)
    • `TensorReduceBoolean` (`all`, `any`)
    • `TensorMatMul` (using `matmul_output_shape` contract)
  • Enforce shape/dimension validation with clear structured errors
  • Preserve explicit unsupported boundaries where required (especially sparse edge paths)

Explicit Non-Goals

  • Transaction lifecycle/LSM logic in `tc-collection`
  • Introducing broad new platform abstractions from `ha-ndarray` beyond what is needed for `fensor`

Acceptance Criteria

  • Math op matrix passes for supported dense/sparse cases:
    • unary, binary, scalar, reductions, matmul
  • All shape/dimension validation failures return structured, user-friendly errors
  • `matmul` validation honors `matmul_output_shape` contract
  • Reduction semantics verified:
    • axis reductions with `keepdims`
    • full reductions (`*_all`)
    • boolean reductions (`all/any`)
  • Chained transform + math correctness is validated
  • Unsupported combinations return structured `Error::Unsupported(...)` (or more specific typed errors when available)
  • No `todo!`, `unimplemented!`, or panic-based placeholders in production math paths

Test Plan

  • Add/extend dedicated math tests in `deps/fensor/tests/`:
    • unary/binary/scalar correctness
    • reduce/reduce_all/reduce_boolean correctness
    • matmul shape and numeric correctness
    • dense/sparse parity where supported
    • transform+math composition cases
  • Include negative tests for:
    • invalid shape combinations
    • incompatible matmul dimensions
    • unsupported sparse execution paths

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions