Browse Source

!15104 [MS][LITE]prepare data when getting inputs

From: @zhaizhiqiang
Reviewed-by: @zhang_xue_tong,@hangangqiang
Signed-off-by: @zhang_xue_tong
pull/15104/MERGE
mindspore-ci-bot Gitee 4 years ago
parent
commit
fcac556d58
2 changed files with 5 additions and 0 deletions
  1. +1
    -0
      mindspore/lite/src/cxx_api/model/model_impl.cc
  2. +4
    -0
      mindspore/lite/tools/benchmark/benchmark.cc

+ 1
- 0
mindspore/lite/src/cxx_api/model/model_impl.cc View File

@@ -213,6 +213,7 @@ std::vector<MSTensor> ModelImpl::GetInputs() {
}
res.resize(inputs.size());
for (size_t i = 0; i < inputs.size(); i++) {
inputs[i]->MutableData(); // prepare data
auto impl = std::shared_ptr<MSTensor::Impl>(new (std::nothrow) MSTensor::Impl(inputs[i]));
if (impl == nullptr || impl->lite_tensor() == nullptr) {
MS_LOG(ERROR) << "Create tensor failed.";


+ 4
- 0
mindspore/lite/tools/benchmark/benchmark.cc View File

@@ -410,6 +410,10 @@ int Benchmark::MarkPerformance() {
uint64_t time_avg = 0;

for (int i = 0; i < flags_->loop_count_; i++) {
auto inputs = session_->GetInputs();
for (auto tensor : inputs) {
tensor->MutableData(); // prepare data
}
session_->BindThread(true);
auto start = GetTimeUs();
auto status = session_->RunGraph(before_call_back_, after_call_back_);


Loading…
Cancel
Save