Skip to content

Commit d332127

Browse files
committed
load model from buffer with length
test=develop
1 parent 325d0cc commit d332127

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

paddle/fluid/inference/api/api_anakin_engine.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,13 @@ template <typename T, Precision P, OpRunType R>
5454
void PaddleInferenceAnakinPredictor<T, P, R>::InitGraph() {
5555
this->graph_p_ =
5656
std::make_shared<anakin::graph::Graph<T, anakin::Precision::FP32>>();
57-
if (!(this->graph_p_->load(this->config_.model_file))) {
58-
LOG(FATAL) << "fail to load graph from " << this->config_.model_file;
57+
if (!this->config_.model_file.empty()) {
58+
this->graph_p_->load(this->config_.model_file);
59+
} else if (this->config_.model_buf_p) {
60+
this->graph_p_->load(this->config_.model_buf_p,
61+
this->config_.model_buf_len);
62+
} else {
63+
LOG(FATAL) << "Model load error.";
5964
}
6065
auto inputs = this->graph_p_->get_ins();
6166
for (auto &input_str : inputs) {

paddle/fluid/inference/api/paddle_anakin_config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ struct AnakinConfig : public PaddlePredictor::Config {
3434
int max_stream{4};
3535
int data_stream_id{0};
3636
int compute_stream_id{0};
37+
char* model_buf_p{nullptr};
38+
size_t model_buf_len{0};
3739
TargetType target_type;
3840
#ifdef ANAKIN_MLU_PLACE
3941
int model_parallel{8};

0 commit comments

Comments
 (0)