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

init

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