ytm._core.backends.buffers.FitBuffers#
- class ytm._core.backends.buffers.FitBuffers#
Bases:
AutoPtrsArrays the fit kernels read and write, kept on the device for a whole epoch.
Work arrays (clause outputs, votes, feedback lists) are made once in
__post_init__.start_epochtakes the epoch’s inputs: per-sample fields (per_sample_fields) stay on the host, the rest are moved to the device.load_chunk(start, end)moves one slice of the per-sample fields to the device, so an epoch can run in chunks that fit in memory.end_epochdrops the epoch’s inputs.With
make_ptrs, every numpy array set as an attribute also gets a ctypes pointerp_<name>for the cpu kernels. It is None when the array is None.- Parameters:
- xpmodule
Array module,
numpyorcupy.- cfgBaseTMConfig
Model config, for sizes and dtypes.
- make_ptrsbool, default=True
Make the
p_<name>pointers. Only the cpu backend needs them.
- Attributes:
- epoch_fieldsdict
The keyword arguments of the last
start_epoch, on the host.- per_sample_fieldstuple of str
Fields with one row per sample, needed for loading chunk by chunk.
- Nint
Total number of samples in the epoch.
- chunk_start, chunk_endint
Sample range
[chunk_start, chunk_end)currently loaded.- Xarray of shape
(chunk, *dim) Inputs of the loaded chunk, cast for the kernels.
- Yarray of shape (chunk, n_classes)
Targets of the loaded chunk.
- rng_keysarray of shape (chunk,)
RNG key of each sample in the loaded chunk.
- clause_drop_maskarray of shape (total_clauses,)
Clauses dropped for the whole epoch (Drop Clause).
- lit_drop_maskarray of shape (n_literals,)
Literals to skip.
- feat_drop_bitsarray of shape (n_bin_feat_chunks,), uint64
All binary features only: bit
fidset when featurefidis skipped. Shape (1,) otherwise.- x_bitsarray of shape (n_patches, n_bin_feat_chunks), uint64
All binary features only: bit packed patches of the current sample. Shape (1,) otherwise.
- class_activearray of shape (n_classes,), uint8
1 when the class gives feedback on the current sample.
- clause_outputarray of shape (total_clauses,)
1 when the clause fired on the current sample.
- selected_pidsarray of shape (total_clauses,)
Selected patch ids for the active clauses. Shape (1,) with one patch.
- votesarray of shape (n_classes,)
Weighted vote sum for the current sample.
- t1b_n, t1a_t2_narray of shape (1,), uint32
Number of valid entries in the T1b list and in the T1a/T2 list.
- t1b_cid, t1a_t2_cidarray of shape (total_clauses,), uint32
Clauses with T1b feedback, and clauses with T1a or T2 feedback, on the current sample.
- t1b_cntarray of shape (total_clauses,)
T1b count over classes, parallel to
t1b_cid.- t1a_cnt, t2_cntarray of shape (total_clauses,)
T1a and T2 counts over classes, parallel to
t1a_t2_cid.