| 371 | } |
| 372 | } |
| 373 | void CPURaster::tensorConvert(Tensor* input, Tensor* output, int bytes) { |
| 374 | std::pair<std::function<void(int)>, int> task; |
| 375 | auto core = static_cast<CPUBackend*>(backend())->functions(); |
| 376 | auto threadNumber = static_cast<CPUBackend*>(backend())->threadNumber(); |
| 377 | if (!mUseThreads) { |
| 378 | threadNumber = 1; |
| 379 | } |
| 380 | task.first = [input, output, bytes, threadNumber, core](int tId) { |
| 381 | auto& subIb = input->buffer(); |
| 382 | auto& subOb = output->buffer(); |
| 383 | auto source = TensorUtils::getDescribe(input)->dimensionFormat; |
| 384 | auto dest = TensorUtils::getDescribe(output)->dimensionFormat; |
| 385 | if (subIb.dimensions <= 1 || source == dest) { |
| 386 | ::memcpy(subOb.host, subIb.host, input->elementSize() * bytes); |
| 387 | return; |
| 388 | } |
| 389 | auto tup = CPUTensorConverter::splitDimensions(subIb, source); |
| 390 | int area = std::get<1>(tup), batch = std::get<0>(tup), channel = std::get<2>(tup); |
| 391 | const int bitLength = bytes; |
| 392 | CPUTensorConverter::convert(subIb.host, subOb.host, source, dest, batch, area, channel, bitLength, core, tId, threadNumber); |
| 393 | }; |
| 394 | task.second = threadNumber; |
| 395 | mTasks.emplace_back(task); |
| 396 | } |
| 397 | ErrorCode CPURaster::onResize(const std::vector<Tensor *> &____inputs, const std::vector<Tensor *> &outputs) { |
| 398 | MNN_ASSERT(outputs.size() == 1); |
| 399 | auto output = outputs[0]; |
nothing calls this directly
no test coverage detected