borch

Learn · 5

Convolution

Images are NCHW — batch, channels, height, width, the same layout as torch. The sister binding used NHWC to work around a TF.js limit; the kernels here have no such limit, so the layout is not inherited.

One convolution

nn.Conv2d(inC, outC, kernel, stride, padding). Shapes follow the usual formula, and the quickest way to be sure is to print them.

A small classifier

Convolution, activation, pooling, twice — then flatten and a linear head. This is the shape of every first CNN, and it trains here in a couple of hundred milliseconds.

What the GPU actually did

The device counts what it was asked to do. These numbers do not depend on the adapter — they are decided by the code path, which is why the repository's cost test can run where a wall-clock benchmark cannot.

1-D and 3-D convolution exist here and not in the numpy core. That is deliberate: the core refuses 53 cases the browser side answers, and asking it anyway would not be a test, it would be a wrong answer. The conformance runner counts those separately instead of hiding them.