MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / EnsurePacked

Method EnsurePacked

tensorflow/lite/experimental/ruy/trmul.cc:194–226  ·  view source on GitHub ↗

Ensures that both the LHS and RHS blocks required by the specified block are packed. In the event that they are already being packed on another threads, this function may perform the packing of some other block while waiting for that other thread to finish packing the requested block.

Source from the content-addressed store, hash-verified

192 // threads, this function may perform the packing of some other block while
193 // waiting for that other thread to finish packing the requested block.
194 void EnsurePacked(const SidePair<int>& block, const SidePair<int>& start,
195 const SidePair<int>& end, Tuning tuning) {
196#if RUY_OPT_ENABLED(RUY_OPT_PACK_AHEAD)
197 SidePair<int> next_runahead_block{block[Side::kLhs] + 1,
198 block[Side::kRhs] + 1};
199 Side next_runahead_side = Side::kLhs;
200#endif
201 while (true) {
202 bool both_sides_packed = true;
203 for (Side side : {Side::kLhs, Side::kRhs}) {
204 both_sides_packed &=
205 TryPack(side, block[side], start[side], end[side], tuning);
206 }
207 if (both_sides_packed) {
208 break;
209 }
210#if RUY_OPT_ENABLED(RUY_OPT_PACK_AHEAD)
211 const Side runahead_side = next_runahead_side;
212 const int runahead_block = next_runahead_block[runahead_side];
213 next_runahead_side =
214 next_runahead_side == Side::kLhs ? Side::kRhs : Side::kLhs;
215 if (runahead_block >= NumBlocksPerSide(runahead_side, block_map)) {
216 continue;
217 }
218 int runahead_block_start, runahead_block_end;
219 GetBlockMatrixCoords(runahead_side, block_map, runahead_block,
220 &runahead_block_start, &runahead_block_end);
221 TryPack(runahead_side, runahead_block, runahead_block_start,
222 runahead_block_end, tuning);
223 next_runahead_block[runahead_side] = runahead_block + 1;
224#endif
225 }
226 }
227
228 TrMulParams* params;
229 const BlockMap& block_map;

Callers

nothing calls this directly

Calls 2

NumBlocksPerSideFunction · 0.85
GetBlockMatrixCoordsFunction · 0.85

Tested by

no test coverage detected