We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
初始化代码: _mnn_net->setCacheFile(".cache"); _net_cfg.type = MNN_FORWARD_OPENCL; DEBUG_LOG(" setCacheFile end "); _mnn_session = _mnn_net->createSession(_net_cfg); _mnn_net->setSessionMode(MNN::Interpreter::Session_Release); _net_cfg.numThread = 4; for (int i = 0; i < 1; ++i) { auto outputTensor = _mnn_net->getSessionOutput(_mnn_session, NULL); MNN::Tensor* input = _mnn_net->getSessionInput(_mnn_session, NULL); void* host = input->map(MNN::Tensor::MAP_TENSOR_WRITE, input->getDimensionType()); input->unmap(MNN::Tensor::MAP_TENSOR_WRITE, input->getDimensionType(), host); _mnn_net->runSession(_mnn_session); host = outputTensor->map(MNN::Tensor::MAP_TENSOR_READ, outputTensor->getDimensionType()); outputTensor->unmap(MNN::Tensor::MAP_TENSOR_READ, outputTensor->getDimensionType(), host); } 推理代码: std::vector<float> inputTensorValues = substractMeanNormalize(inputImage, meanValues, normValues); auto input = _mnn_net->getSessionInput(_mnn_session, NULL); auto shape = input->shape(); shape[0] = 1; shape[2] = inputImage.rows; shape[3] = inputImage.cols; _mnn_net->resizeTensor(input, shape); _mnn_net->resizeSession(_mnn_session); auto shapein = input->shape(); std::vector<int> v = {1, (int)inputImage.channels(), inputImage.rows, inputImage.cols}; auto nchwTensor = MNN::Tensor::create(v, halide_type_of<float>(), &inputTensorValues[0], MNN::Tensor::CAFFE); input->copyFromHostTensor(nchwTensor); delete nchwTensor; _mnn_net->runSession(_mnn_session); outputs = _mnn_net->getSessionOutputAll(_mnn_session); 获取结果代码: out_dim.push_back(out_shape_c); out_dim.push_back(out_shape_h); out_dim.push_back(out_shape_w); float* data_ptr = tensor_ptr->host<float>(); DEBUG_LOG(" *obj_angle_ptr :%f ",results[105600]); 其中out_shape_c=67,out_shape_h=40,out_shape_w=40
The text was updated successfully, but these errors were encountered:
这个 tensor_ptr 是什么?如果使用 opencl ,不能直接使用 host ,需要用 map ,用完后 unmp
Sorry, something went wrong.
Marking as stale. No activity in 60 days.
No branches or pull requests
The text was updated successfully, but these errors were encountered: