提交 8310c8f9 编写于 作者: S superjomn

init

上级 7cf536f0
...@@ -61,5 +61,24 @@ const framework::proto::ProgramDesc &Predictor::program_desc() const { ...@@ -61,5 +61,24 @@ const framework::proto::ProgramDesc &Predictor::program_desc() const {
return program_desc_; return program_desc_;
} }
void Predictor::Build(const framework::proto::ProgramDesc &desc,
const Place &prefer_place,
const std::vector<Place> &valid_places) {
program_desc_ = desc;
Program program(desc, scope_, valid_places);
optimizer_.KernelPickPreferPlace(prefer_place);
core::KernelPickFactor factor;
factor.ConsiderTarget();
factor.ConsiderPrecision();
optimizer_.Run(std::move(program), valid_places, factor);
program_ = optimizer_.GenRuntimeProgram();
}
const lite::Tensor *Predictor::GetTensor(const std::string &name) const {
auto *var = program_->exec_scope()->FindVar(name);
return &var->Get<lite::Tensor>();
}
} // namespace lite } // namespace lite
} // namespace paddle } // namespace paddle
...@@ -42,18 +42,7 @@ class Predictor { ...@@ -42,18 +42,7 @@ class Predictor {
const std::vector<Place>& valid_places); const std::vector<Place>& valid_places);
void Build(const framework::proto::ProgramDesc& desc, void Build(const framework::proto::ProgramDesc& desc,
const Place& prefer_place, const Place& prefer_place, const std::vector<Place>& valid_places);
const std::vector<Place>& valid_places) {
program_desc_ = desc;
Program program(desc, scope_, valid_places);
optimizer_.KernelPickPreferPlace(prefer_place);
core::KernelPickFactor factor;
factor.ConsiderTarget();
factor.ConsiderPrecision();
optimizer_.Run(std::move(program), valid_places, factor);
program_ = optimizer_.GenRuntimeProgram();
}
// Run the predictor for a single batch of data. // Run the predictor for a single batch of data.
void Run() { program_->Run(); } void Run() { program_->Run(); }
...@@ -66,10 +55,7 @@ class Predictor { ...@@ -66,10 +55,7 @@ class Predictor {
// Return the program desc for debug. // Return the program desc for debug.
const framework::proto::ProgramDesc& program_desc() const; const framework::proto::ProgramDesc& program_desc() const;
const lite::Tensor* GetTensor(const std::string& name) const { const lite::Tensor* GetTensor(const std::string& name) const;
auto* var = program_->exec_scope()->FindVar(name);
return &var->Get<lite::Tensor>();
}
// This method is disabled in mobile, for unnecessary dependencies required. // This method is disabled in mobile, for unnecessary dependencies required.
void SaveModel(const std::string& dir); void SaveModel(const std::string& dir);
......
...@@ -14,9 +14,7 @@ ...@@ -14,9 +14,7 @@
#pragma once #pragma once
#ifndef LITE_WITH_ARM #include <sys/stat.h>
#include <bits/stdc++.h>
#endif
#include <fstream> #include <fstream>
#include <string> #include <string>
#include "paddle/fluid/lite/utils/cp_logging.h" #include "paddle/fluid/lite/utils/cp_logging.h"
...@@ -35,12 +33,14 @@ static bool IsFileExists(const std::string& path) { ...@@ -35,12 +33,14 @@ static bool IsFileExists(const std::string& path) {
} }
// ARM mobile not support mkdir in C++ // ARM mobile not support mkdir in C++
#ifndef LITE_WITH_ARM
static void MkDirRecur(const std::string& path) { static void MkDirRecur(const std::string& path) {
#ifndef LITE_WITH_ARM
CHECK_EQ(system(string_format("mkdir -p %s", path.c_str()).c_str()), 0) CHECK_EQ(system(string_format("mkdir -p %s", path.c_str()).c_str()), 0)
<< "Cann't mkdir " << path; << "Cann't mkdir " << path;
} #else // On ARM
CHECK_NE(mkddir(path.c_str(), S_IRWXU), -1) << "Cann't mkdir " << path;
#endif #endif
}
} // namespace lite } // namespace lite
} // namespace paddle } // namespace paddle
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册