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

Method getTensorSize

source/backend/cpu/CPUBackend.cpp:682–698  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

680}
681
682size_t CPUBackend::getTensorSize(const Tensor* tensor, bool multiBytes) const {
683 auto core = mCoreFunctions;
684 size_t dataSize = 1;
685 auto des = TensorUtils::getDescribe(tensor);
686 for (int i = 0; i < tensor->dimensions(); i++) {
687 size_t currentDimSize = tensor->length(i);
688 if (des->dimensionFormat == MNN_DATA_FORMAT_NC4HW4 && 1 == i) {
689 currentDimSize = UP_DIV(currentDimSize, core->pack) * core->pack;
690 }
691 dataSize *= currentDimSize;
692 }
693 if (multiBytes) {
694 size_t bytes = getBytes(this, tensor);
695 return dataSize * bytes;
696 }
697 return dataSize;
698}
699
700size_t CPUBackend::getBytes(const Backend* backend, const Tensor* output) {
701 size_t bytes = output->getType().bytes();

Callers 15

onResizeMethod · 0.45
onExecuteMethod · 0.45
onExecuteMethod · 0.45
onExecuteMethod · 0.45
onExecuteMethod · 0.45
onExecuteMethod · 0.45
onExecuteMethod · 0.45
onResizeMethod · 0.45
onExecuteMethod · 0.45
onResizeMethod · 0.45
onExecuteMethod · 0.45
onExecuteMethod · 0.45

Calls 2

dimensionsMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected