提交 dd2bd8e3 编写于 作者: C Chunwei

update

上级 b78b416f
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#pragma once #pragma once
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include <numeric>
#include "memory.h" #include "memory.h"
namespace paddle { namespace paddle {
......
...@@ -132,6 +132,12 @@ std::unique_ptr<framework::proto::ProgramDesc> LoadProgram( ...@@ -132,6 +132,12 @@ std::unique_ptr<framework::proto::ProgramDesc> LoadProgram(
void LoadParams(const std::string &path) {} void LoadParams(const std::string &path) {}
// Load directly to CPU, and latter transfer to other devices.
void LoadParam(const std::string &path, Variable *out) {
std::ifstream fin(path, std::ios::binary);
LoadLoDTensor(fin, out);
}
void LoadModel(const std::string &model_dir, Scope *scope) { void LoadModel(const std::string &model_dir, Scope *scope) {
const std::string prog_path = model_dir + "/__model__"; const std::string prog_path = model_dir + "/__model__";
auto prog = LoadProgram(prog_path); auto prog = LoadProgram(prog_path);
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "paddle/fluid/framework/framework.pb.h" #include "paddle/fluid/framework/framework.pb.h"
#include "paddle/fluid/lite/core/tensor.h"
#include "paddle/fluid/lite/core/variable.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -30,6 +32,9 @@ std::unique_ptr<framework::proto::ProgramDesc> LoadProgram( ...@@ -30,6 +32,9 @@ std::unique_ptr<framework::proto::ProgramDesc> LoadProgram(
// Read a single file containing all the parameters. // Read a single file containing all the parameters.
void LoadParams(const std::string& path); void LoadParams(const std::string& path);
// Load a single parameter to an output tensor.
void LoadParam(const std::string& path, Variable* out);
// Read a model and files of parameters. // Read a model and files of parameters.
void LoadModel(const std::string& model_dir); void LoadModel(const std::string& model_dir);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册