op_repository.cpp 1.3 KB
Newer Older
W
wangguibao 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
#include "framework/op_repository.h"
#include "op/op.h"

namespace baidu {
namespace paddle_serving {
namespace predictor {

Op* OpRepository::get_op(std::string op_type) {
    ManagerMap::iterator iter = _repository.find(op_type);
    Op* op = NULL;
    if (iter != _repository.end()) {
        op = (iter->second)->get_op();
    } else {
14
        LOG(ERROR) << "Try to create unknown op[" << op_type << "]";
W
wangguibao 已提交
15 16 17 18 19 20
    }
    return op;
}

void OpRepository::return_op(Op* op) {
    if (op == NULL) {
21
        LOG(ERROR) << "Try to return NULL op";
W
wangguibao 已提交
22 23 24 25 26 27
        return;
    }
    ManagerMap::iterator iter = _repository.find(op->type());
    if (iter != _repository.end()) {
        iter->second->return_op(op);
    } else {
28
        LOG(ERROR) << "Try to return unknown op[" << op << "], op_type["
W
wangguibao 已提交
29 30 31 32 33 34
                << op->type() << "].";
    }
}

void OpRepository::return_op(const std::string& op_type, Op* op) {
    if (op == NULL) {
35
        LOG(ERROR) << "Try to return NULL op";
W
wangguibao 已提交
36 37 38 39 40 41
        return;
    }
    ManagerMap::iterator iter = _repository.find(op_type);
    if (iter != _repository.end()) {
        iter->second->return_op(op);
    } else {
42
        LOG(ERROR) << "Try to return unknown op[" << op << "], op_type["
W
wangguibao 已提交
43 44 45 46 47 48 49
                << op_type << "].";
    }
}

} // namespace predictor
} // namespace paddle_serving
} // namespace baidu