nndeploy C++ API  0.2.0
nndeploy C++ API
prefill.h
Go to the documentation of this file.
1 // 将tokenizer + embedding + infer + sample 封装成一个图
2 #ifndef _NNDEPLOY_LLM_PREFILL_H_
3 #define _NNDEPLOY_LLM_PREFILL_H_
4 
5 #include "nndeploy/dag/graph.h"
8 #include "nndeploy/llm/prompt.h"
9 #include "nndeploy/llm/sample.h"
11 
12 namespace nndeploy {
13 namespace llm {
14 
15 class Prefill : public dag::Graph {
16  public:
17  Prefill(const std::string& name, std::vector<dag::Edge*> inputs,
18  std::vector<dag::Edge*> outputs);
19  Prefill(const std::string& name);
20  virtual ~Prefill();
21 
22  virtual base::Status make(const dag::NodeDesc& tokenizer,
23  const dag::NodeDesc& infer,
24  const dag::NodeDesc& sample);
25 
26  virtual std::vector<dag::Edge*> forward(dag::Edge* input) override;
27 
28  private:
29  dag::Node* prefill_token_node_ = nullptr;
30  llm::LlmInfer* prefill_infer_node_ = nullptr;
31  dag::Node* prefill_sampler_node_ = nullptr;
32 };
33 
34 } // namespace llm
35 } // namespace nndeploy
36 
37 #endif
Edge class in DAG graph for connecting nodes and transferring data.
Definition: edge.h:35
Directed Acyclic Graph Node.
Definition: graph.h:31
Node description class.
Definition: node.h:35
Node base class.
Definition: node.h:171
LlmInfer - LLM推理节点
Definition: llm_infer.h:47
Prefill(const std::string &name, std::vector< dag::Edge * > inputs, std::vector< dag::Edge * > outputs)
Prefill(const std::string &name)
virtual std::vector< dag::Edge * > forward(dag::Edge *input) override
Forward propagation (single input version)
virtual base::Status make(const dag::NodeDesc &tokenizer, const dag::NodeDesc &infer, const dag::NodeDesc &sample)