Add that allocates

In-place add mutates the left tensor. The next contract is different: two tensors in, a third out, nobody overwritten. That does not belong as another method on the type. src/tensor/ops.zig appears. ops.add(T, allocator, a, b) checks shape, checks stride, initCpus a zeroed output, writes dst.* = a + b, returns it. Tests live in their own file. lib.zig re-exports ops.

The file is a place to layer. Linear, conv, reductions can land here later. Today it is one function. The in-place method stays on Tensor. Both are add. They are not the same API.

df90e02 · d15bc2b

Previous · Next