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

Method tensorConvert

source/backend/cpu/CPURaster.cpp:373–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371 }
372}
373void 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}
397ErrorCode CPURaster::onResize(const std::vector<Tensor *> &____inputs, const std::vector<Tensor *> &outputs) {
398 MNN_ASSERT(outputs.size() == 1);
399 auto output = outputs[0];

Callers

nothing calls this directly

Calls 5

backendFunction · 0.85
functionsMethod · 0.80
threadNumberMethod · 0.80
convertFunction · 0.50
bufferMethod · 0.45

Tested by

no test coverage detected