mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-11 11:30:20 +08:00
[Other] Optimize code style (#1032)
* Optimize code * optimize code * optimize code * fix compile error
This commit is contained in:
@@ -341,8 +341,7 @@ int OpenVINOBackend::NumInputs() const { return input_infos_.size(); }
|
||||
int OpenVINOBackend::NumOutputs() const { return output_infos_.size(); }
|
||||
|
||||
bool OpenVINOBackend::Infer(std::vector<FDTensor>& inputs,
|
||||
std::vector<FDTensor>* outputs,
|
||||
bool copy_to_fd) {
|
||||
std::vector<FDTensor>* outputs, bool copy_to_fd) {
|
||||
if (inputs.size() != input_infos_.size()) {
|
||||
FDERROR << "[OpenVINOBackend] Size of the inputs(" << inputs.size()
|
||||
<< ") should keep same with the inputs of this model("
|
||||
@@ -365,19 +364,17 @@ bool OpenVINOBackend::Infer(std::vector<FDTensor>& inputs,
|
||||
auto out_tensor_shape = out_tensor.get_shape();
|
||||
std::vector<int64_t> shape(out_tensor_shape.begin(),
|
||||
out_tensor_shape.end());
|
||||
if(copy_to_fd) {
|
||||
(*outputs)[i].Resize(shape,
|
||||
if (copy_to_fd) {
|
||||
(*outputs)[i].Resize(shape,
|
||||
OpenVINODataTypeToFD(out_tensor.get_element_type()),
|
||||
output_infos_[i].name,
|
||||
Device::CPU);
|
||||
output_infos_[i].name, Device::CPU);
|
||||
memcpy((*outputs)[i].MutableData(), out_tensor.data(),
|
||||
(*outputs)[i].Nbytes());
|
||||
(*outputs)[i].Nbytes());
|
||||
} else {
|
||||
(*outputs)[i].name = output_infos_[i].name;
|
||||
(*outputs)[i].SetExternalData(shape,
|
||||
OpenVINODataTypeToFD(out_tensor.get_element_type()),
|
||||
out_tensor.data(),
|
||||
Device::CPU);
|
||||
(*outputs)[i].SetExternalData(
|
||||
shape, OpenVINODataTypeToFD(out_tensor.get_element_type()),
|
||||
out_tensor.data(), Device::CPU);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user