Skip to content
class

EmbeddingBags

EmbeddingBags

The bags of an EmbeddingBag over n_idx indices: bag b is [start[b], end[b]). Under include_last_offset the final offset is a sentinel that ends the last bag, so there is one bag fewer than offsets; otherwise the last bag runs to the end of the indices. The forward and the backward both read them here, so they cannot disagree about which indices a bag owns. An offset outside [0, n_idx] would walk the index buffer past its end, so it is refused.