cvimg2Tensor的三次通道合并是否可提升性能?
gemfield opened this issue · comments
cvimg2Tensor的三次通道合并是否可提升性能?
std::vector<double> mean({0.485, 0.456, 0.406});
std::vector<double> std({0.229, 0.224, 0.225});
at::Tensor mean_ = at::tensor(mean).view({1, 3, 1, 1});
at::Tensor std_ = at::tensor(std).view({1, 3, 1, 1});
auto start = std::chrono::system_clock::now();
input_tensor = input_tensor.sub_(mean_).div_(std_);
std::chrono::duration<double> model_loading_duration = std::chrono::system_clock::now() - start;
std::string msg = gemfield_org::format("input_tensor.sub_(mean_).div_(std_) time: %f", model_loading_duration.count());
std::cout<<msg<<std::endl;
input_tensor = input_tensor.sub_(mean_).div_(std_) 时间大约在50ms,比较慢