提交 dd2bd8e3 编写于 作者: C Chunwei

update

上级 b78b416f
......@@ -15,6 +15,7 @@
#pragma once
#include <algorithm>
#include <vector>
#include <numeric>
#include "memory.h"
namespace paddle {
......
......@@ -132,6 +132,12 @@ std::unique_ptr<framework::proto::ProgramDesc> LoadProgram(
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) {
const std::string prog_path = model_dir + "/__model__";
auto prog = LoadProgram(prog_path);
......
......@@ -19,6 +19,8 @@
#include <string>
#include <vector>
#include "paddle/fluid/framework/framework.pb.h"
#include "paddle/fluid/lite/core/tensor.h"
#include "paddle/fluid/lite/core/variable.h"
namespace paddle {
namespace lite {
......@@ -30,6 +32,9 @@ std::unique_ptr<framework::proto::ProgramDesc> LoadProgram(
// Read a single file containing all the parameters.
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.
void LoadModel(const std::string& model_dir);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册