Maths

Contiguous tensor containers (Tensor1D, PayloadTensor1D, Tensor2D, Tensor3D) and thread-local RealStorage checkpoint width guards.

class Tensor1D JBit · Maths/Tensor1D.hpp · 7 members

Contiguous 1D tensor of real_t elements with N-D flattenedSizes metadata, vectorized math, spatial padding, and Transformer batch payloads.

enum TENSOR_CONTEXT
enum TENSOR_CONTEXT { NORMAL = 0, TRANSFORMER_BATCH_PAYLOAD, tensor_context_count };
static Tensor1D zeros(size_t size) / ones(size_t size) / fromValues(std::initializer_list<real_t> values);
void setFlattenedSizes(const std::vector<size_t> &sizes) / const std::vector<size_t> &getFlattenedSizes() const;
size_t getSize() const / real_t *getPointer() / std::vector<real_t> &getData();
Tensor1D vMultiply(...) / vPow(real_t p) / vAbs() / vLog() / vExp() / vMax(real_t eps) const;
size_t maxValueIndex(size_t minIndex = 0, int64_t maxIndex = -1) const / real_t maxValue(...) const;
Tensor1D padding2D(const std::vector<size_t> &padding, size_t rows, size_t cols, real_t value = 0.0f) const;
virtual void save(std::ostream &os) const / virtual void load(std::istream &is);
class PayloadTensor1D JBit · Maths/PayloadTensor1D.hpp · 4 members

Tensor1D carrying BatchPayload (inputIds, attentionMask, tokenTypeIds, labels) for packed Transformer pre-training and SFT.

inherits Tensor1D
PayloadTensor1D *toTrainingDecoderInput();
void appendWithEosSos(const PayloadTensor1D &other) / appendWithSep(...) / appendWithPad(...) / appendWithIgnore(...);
void segmentBySos(); Assigns incrementing 1-based segment IDs in attentionMask so packed sequences never attend across [sos].
void ensureSosEos() / ensureSos() / ensureEos() / stripOuterSosEos() / toPadding() / toIgnore();
class Tensor2D JBit · Maths/Tensor2D.hpp · 3 members

Row-major 2D matrix with matrix-matrix and matrix-vector operators.

Tensor2D(size_t rowCount, size_t colCount);
Tensor2D operator*(const Tensor2D &other) const / Tensor1D operator*(const Tensor1D &tensor) const;
size_t getRowCount() const / size_t getColCount() const / size_t getSize() const;
class Tensor3D JBit · Maths/Tensor3D.hpp · 2 members

Contiguous 3D [depth, rows, cols] tensor with proxy indexing t[c][r][col].

Tensor3D(size_t deeperCount, size_t rowCount, size_t colCount);
ChannelProxy operator[](size_t c) / real_t &operator()(size_t c, size_t r, size_t col);
class Scope JBit::RealStorage · Maths/RealStorage.hpp · 2 members

RAII guard setting checkpoint byte width (2 = FP16, 4 = FP32, 8 = FP64) for the current thread and restoring on exit.

explicit Scope(size_t write, size_t read);
~Scope();
Free functions & typedefs1
inline void writeReals(std::ostream &os, const real_t *p, size_t n) / readReals(std::istream &is, real_t *p, size_t n);