MCPcopy Create free account
hub / github.com/ml-explore/mlx-data / get

Method get

mlx/data/buffer/Batch.cpp:52–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52Sample Batch::get(int64_t idx) const {
53 if (idx < 0 || idx >= size_) {
54 throw std::runtime_error("Batch: index out of range");
55 }
56 auto batch_size =
57 (batchSize_ ? std::min(batchSize_, op_->size() - idx * batchSize_)
58 : batchSizes_[idx]);
59 auto batch_offset = (batchSize_ ? idx * batchSize_ : batchOffsets_[idx]);
60 std::vector<Sample> samples(batch_size);
61 for (int64_t i = 0; i < batch_size; i++) {
62 samples[i] = op_->get(batch_offset + i);
63 }
64 return core::merge_batch(samples, padValues_, batchDims_);
65}
66
67int64_t Batch::size() const {
68 return size_;

Callers

nothing calls this directly

Calls 2

merge_batchFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected