microsoft / microsoft/bocpy

`Tensor` v1: contiguous N-D arrays

Open
#21 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

maths
Dominant language
Python
Stars
184
Forks
9
PR merge metrics
No merged PRs in 30d

Description

Problem

bocpy ships a dense 2-D Matrix and nothing else. Anything users do that is naturally N-dimensional — image stacks, batched feature tensors, multi-channel audio, simulation grids, anything with a leading batch axis — has to be flattened by hand or coordinated as a Python list of Matrix objects. Both lose the in-place, cown-friendly arithmetic that makes Matrix worth using in the first place.

Desired functionality

A first-class Tensor Python type with arbitrary-rank contiguous storage of doubles, the same arithmetic surface as Matrix (elementwise binary, elementwise unary, scalar binary, aggregates with optional axis=), and the same cown / sub-interpreter round-trip story. Users should be able to put a Tensor inside a Cown, mutate it from a behavior, and observe the change in the next behavior, exactly as they do today with Matrix.

Constraints

  • Contiguous storage only — no strides, no views, no transpose-without-copy.
  • Same-shape binary ops only; mismatched shapes raise immediately.
  • No matmul on Tensor. Rank-2 linear algebra stays on Matrix.
  • Matrix is untouched by this work.

Out of scope

Broadcasting, full Matrix-parity indexing, Matrix/Tensor unification, views, reshape, fancy indexing.

Open questions

  • Are rank-0 tensors a valid shape?
  • Does a rank-reducing aggregate on a rank-k Tensor always return a rank-k-1 Tensor, including the rank-1 → rank-0 case?
  • Constructor shape: a single positional shape tuple, named factory methods, or both?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing Matrix implementation, its arithmetic and aggregate tests, and the Cown/sub-interpreter round-trip coverage. Resolve the listed rank, aggregate, and constructor questions before implementing the Tensor scope; done means contiguous arbitrary-rank double storage, the specified arithmetic and aggregates, shape validation, and the requested Cown behavior without changing Matrix.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.