nndeploy C++ API  0.2.0
nndeploy C++ API
infer.h
Go to the documentation of this file.
1 
2 #ifndef _NNDEPLOY_INFER_INFER_H_
3 #define _NNDEPLOY_INFER_INFER_H_
4 
5 #include "nndeploy/dag/node.h"
8 
9 namespace nndeploy {
10 namespace infer {
11 
13  public:
14  Infer(const std::string &name);
15  Infer(const std::string &name, std::vector<dag::Edge *> inputs,
16  std::vector<dag::Edge *> outputs);
17 
18  Infer(const std::string &name, base::InferenceType type);
19  Infer(const std::string &name, std::vector<dag::Edge *> inputs,
20  std::vector<dag::Edge *> outputs, base::InferenceType type);
21 
22  virtual ~Infer();
23 
24  virtual base::Status setInputName(const std::string &name, int index = 0);
25  virtual base::Status setOutputName(const std::string &name, int index = 0);
26  virtual base::Status setInputNames(const std::vector<std::string> &names);
27  virtual base::Status setOutputNames(const std::vector<std::string> &names);
28 
30 
32  virtual base::Param *getParam();
33 
34  virtual base::Status setParamSharedPtr(std::shared_ptr<base::Param> param);
35  virtual std::shared_ptr<base::Param> getParamSharedPtr();
36 
38 
39  virtual base::Status init();
40  virtual base::Status deinit();
41 
42  virtual int64_t getMemorySize();
44 
45  virtual base::Status run();
46 
47  virtual std::shared_ptr<inference::Inference> getInference();
48 
49  virtual base::Status serialize(rapidjson::Value &json,
50  rapidjson::Document::AllocatorType &allocator);
51  virtual base::Status deserialize(rapidjson::Value &json);
52 
53  private:
55  bool own_inference_ = true;
56  std::shared_ptr<inference::Inference> inference_ = nullptr;
57 
58  std::set<std::string> inference_input_names_;
59  std::set<std::string> inference_output_names_;
60 
61  bool is_input_dynamic_ = false;
62  bool is_output_dynamic_ = false;
63  bool can_op_input_ = false;
64  bool can_op_output_ = false;
65 };
66 
67 } // namespace infer
68 } // namespace nndeploy
69 
70 #endif /* _NNDEPLOY_INFER_INFER_H_ */
Node base class.
Definition: node.h:171
virtual base::Param * getParam()
Get parameter.
virtual base::Status setInferenceType(base::InferenceType inference_type)
virtual base::Status shareInference(Infer *infer)
virtual std::shared_ptr< inference::Inference > getInference()
virtual base::Status setOutputName(const std::string &name, int index=0)
Set output edge name.
virtual base::Status setMemory(device::Buffer *buffer)
Set memory buffer.
virtual base::Status setParam(base::Param *param)
Set parameter.
virtual base::Status run()
Run node (pure virtual function)
virtual base::Status serialize(rapidjson::Value &json, rapidjson::Document::AllocatorType &allocator)
Serialize to JSON.
virtual std::shared_ptr< base::Param > getParamSharedPtr()
Get parameter (shared pointer)
Infer(const std::string &name, std::vector< dag::Edge * > inputs, std::vector< dag::Edge * > outputs, base::InferenceType type)
virtual base::Status setInputName(const std::string &name, int index=0)
Set input edge name.
virtual base::Status setParamSharedPtr(std::shared_ptr< base::Param > param)
Set parameter (shared pointer)
Infer(const std::string &name)
Infer(const std::string &name, std::vector< dag::Edge * > inputs, std::vector< dag::Edge * > outputs)
virtual base::Status deserialize(rapidjson::Value &json)
Deserialize from JSON.
virtual base::Status deinit()
Deinitialize node.
virtual int64_t getMemorySize()
Get memory size.
virtual base::Status init()
Initialize node.
virtual base::Status setInputNames(const std::vector< std::string > &names)
Set all input edge names.
Infer(const std::string &name, base::InferenceType type)
virtual base::Status setOutputNames(const std::vector< std::string > &names)
Set all output edge names.
#define NNDEPLOY_CC_API
api
Definition: macro.h:29
@ kInferenceTypeNotSupport
Definition: common.h:329