nndeploy C++ API  0.2.0
nndeploy C++ API
Public Member Functions | Public Attributes | List of all members
nndeploy::ir::Interpret Class Referenceabstract

#include <interpret.h>

Inheritance diagram for nndeploy::ir::Interpret:
[legend]
Collaboration diagram for nndeploy::ir::Interpret:
[legend]

Public Member Functions

base::Status dump (std::ostream &oss=std::cout)
 
ModelDescgetModelDesc ()
 获取模型描述 More...
 
virtual base::Status interpret (const std::vector< std::string > &model_value, const std::vector< ValueDesc > &input=std::vector< ValueDesc >())=0
 解释模型 More...
 
 Interpret (ModelDesc *model_desc=nullptr, bool is_external=false)
 解释器类的默认构造函数 More...
 
base::Status saveModelToFile (const std::string &structure_file_path, const std::string &weight_file_path)
 存储模型结构以及模型权重 More...
 
virtual ~Interpret ()
 虚析构函数 More...
 

Public Attributes

bool is_external_ = false
 是否是外部模型 More...
 
ModelDescmodel_desc_ = nullptr
 模型描述 More...
 

Detailed Description

Definition at line 10 of file interpret.h.

Constructor & Destructor Documentation

◆ Interpret()

nndeploy::ir::Interpret::Interpret ( ModelDesc model_desc = nullptr,
bool  is_external = false 
)
explicit

解释器类的默认构造函数

创建一个新的Interpret对象,并初始化model_desc_成员。 model_desc_被初始化为一个新的ModelDesc对象。

解释器类的带参构造函数

使用已有的model_desc创建一个新的Interpret对象。

◆ ~Interpret()

virtual nndeploy::ir::Interpret::~Interpret ( )
virtual

虚析构函数

负责清理Interpret对象,释放model_desc_指针指向的内存

Member Function Documentation

◆ dump()

base::Status nndeploy::ir::Interpret::dump ( std::ostream &  oss = std::cout)

◆ getModelDesc()

ModelDesc* nndeploy::ir::Interpret::getModelDesc ( )

获取模型描述

获取模型描述

Returns
模型描述

◆ interpret()

virtual base::Status nndeploy::ir::Interpret::interpret ( const std::vector< std::string > &  model_value,
const std::vector< ValueDesc > &  input = std::vector< ValueDesc >() 
)
pure virtual

解释模型

该函数负责解释输入的模型,将其转换为内部的中间表示(IR)格式。 这个过程通常包括解析模型结构、提取参数、分析计算图等步骤。

Parameters
model_value包含模型信息的字符串向量。可能包含模型文件路径、序列化的模型数据等。
input模型输入的描述信息。默认为空向量,表示使用模型的默认输入配置。 当需要自定义输入时,可以通过此参数指定。
Returns
base::Status 返回解释过程的状态。
  • 如果解释成功,返回 base::kStatusCodeOk
  • 如果解释失败,返回对应的错误状态码
Note
这是一个纯虚函数,需要在派生类中实现具体的解释逻辑。 不同的模型格式(如ONNX、TensorFlow等)可能需要不同的解释实现。
See also
ValueDesc 了解输入描述的详细信息
base::Status 了解可能的返回状态

Implemented in nndeploy::ir::DefaultInterpret.

◆ saveModelToFile()

base::Status nndeploy::ir::Interpret::saveModelToFile ( const std::string &  structure_file_path,
const std::string &  weight_file_path 
)

存储模型结构以及模型权重

该函数负责将模型的结构和权重存储到指定的输出流中。 这个过程通常包括序列化模型结构、序列化模型权重等步骤。

Parameters
structure_stream输出流,用于存储模型结构的序列化数据。
weight_file_path输出流,用于存储模型权重的序列化数据。
Returns
base::Status 返回存储过程的状态。
  • 如果存储成功,返回 base::kStatusCodeOk
  • 如果存储失败,返回对应的错误状态码
Note
这是一个虚函数,可以在派生类中重载以实现特定的存储逻辑。
See also
base::Status 了解可能的返回状态

存储模型结构以及模型权重到指定路径

该函数负责将模型的结构和权重存储到指定的输出流中。 这个过程通常包括序列化模型结构、序列化模型权重等步骤。

Parameters
structure_file_path输出流,用于存储模型结构的序列化数据。
weight_file_path输出流,用于存储模型权重的序列化数据。
Returns
base::Status 返回存储过程的状态。
  • 如果存储成功,返回 base::kStatusCodeOk
  • 如果存储失败,返回对应的错误状态码
Note
这是一个虚函数,可以在派生类中重载以实现特定的存储逻辑。
See also
base::Status 了解可能的返回状态

Member Data Documentation

◆ is_external_

bool nndeploy::ir::Interpret::is_external_ = false

是否是外部模型

Definition at line 130 of file interpret.h.

◆ model_desc_

ModelDesc* nndeploy::ir::Interpret::model_desc_ = nullptr

模型描述

用于存储模型描述信息

Definition at line 125 of file interpret.h.


The documentation for this class was generated from the following file: