| 680 | } |
| 681 | |
| 682 | size_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 | |
| 700 | size_t CPUBackend::getBytes(const Backend* backend, const Tensor* output) { |
| 701 | size_t bytes = output->getType().bytes(); |
no test coverage detected