MCPcopy Create free account
hub / github.com/alibaba/MNN / getRasterCacheCreateRecursive

Method getRasterCacheCreateRecursive

source/geometry/GeometryComputer.cpp:283–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281}
282
283void GeometryComputer::Context::getRasterCacheCreateRecursive(Tensor* src, CommandBuffer& cmd) {
284 auto srcDes = TensorUtils::getDescribe(src);
285 if (!_virtualMemory(srcDes)) {
286 return;
287 }
288 if (_hasZeroDim(src)) {
289 return;
290 }
291 bool needDelete = false;
292 bool supportFuse = support(Interpreter::GEOMETRCOMPUTEMASK_FUSEREGION);
293 bool supportFuseMulti = support(Interpreter::GEOMETRCOMPUTEMASK_FUSEREGION_MULTI);
294 for (int regIndex = 0; regIndex < srcDes->regions.size();) {
295 auto input = srcDes->regions.data() + regIndex;
296 MNN_ASSERT(input->origin != src);
297
298 auto inputDes = TensorUtils::getDescribe(input->origin);
299 while (_virtualMemory(inputDes) && supportFuse) {
300 if (0 == inputDes->regions.size()) {
301 // Empty Input, Remove the region by set size as 0
302 input->size[0] = 0;
303 needDelete = true;
304 break;
305 }
306 if (1 < inputDes->regions.size()) {
307 if (!supportFuseMulti) {
308 break;
309 }
310 bool allCanMerge = true;
311 for (auto& reg : inputDes->regions) {
312 allCanMerge = allCanMerge && mFuseUtils.match(reg, *input);
313 if (!allCanMerge) {
314 break;
315 }
316 }
317 if (!allCanMerge) {
318 break;
319 }
320 Tensor::InsideDescribe::Region backup = *input;
321 mFuseUtils.match(inputDes->regions[0], *input);
322 mFuseUtils.apply(inputDes->regions[0], *input);
323 for (int i=1; i<inputDes->regions.size(); ++i) {
324 auto newReg = backup;
325 mFuseUtils.match(inputDes->regions[i], newReg);
326 mFuseUtils.apply(inputDes->regions[i], newReg);
327 if (newReg.size[0] == 0) {
328 continue;
329 }
330 srcDes->regions.emplace_back(newReg);
331 }
332 // After emplace_back, the input will change, reref it
333 input = srcDes->regions.data() + regIndex;
334 if (input->size[0] == 0) {
335 needDelete = true;
336 break;
337 }
338 inputDes = TensorUtils::getDescribe(input->origin);
339 continue;
340 }

Callers 3

makeRasterMethod · 0.80
createMethod · 0.80

Calls 6

_virtualMemoryFunction · 0.85
_hasZeroDimFunction · 0.85
sizeMethod · 0.45
dataMethod · 0.45
matchMethod · 0.45
applyMethod · 0.45

Tested by

no test coverage detected