RknnToolkit.Net 1.6.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package RknnToolkit.Net --version 1.6.0
                    
NuGet\Install-Package RknnToolkit.Net -Version 1.6.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RknnToolkit.Net" Version="1.6.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RknnToolkit.Net" Version="1.6.0" />
                    
Directory.Packages.props
<PackageReference Include="RknnToolkit.Net" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RknnToolkit.Net --version 1.6.0
                    
#r "nuget: RknnToolkit.Net, 1.6.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package RknnToolkit.Net@1.6.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RknnToolkit.Net&version=1.6.0
                    
Install as a Cake Addin
#tool nuget:?package=RknnToolkit.Net&version=1.6.0
                    
Install as a Cake Tool

RknnToolkit.Net

RknnToolkit.Net 是一个用于在 RK3588 SBC(如 Rhino SBC)上运行 rknn 模型的 .NET 库。目前,该项目仅支持 sbyte 类型的输出。

安装

您可以通过 NuGet 包管理器安装 RknnToolkit.Net:

Install-Package RknnToolkit.Net

或者,您可以在项目文件中添加以下引用:

<PackageReference Include="RknnToolkit.Net" Version="1.0.0" />

前置条件

  • RK3588 SBC
  • 已安装 .NET 8.0 SDK
  • 已安装 C++ Build Tools
  • 已安装 onnxruntime 1.16.0

使用方法

初始化模型

使用 InitModel 方法初始化模型:

IntPtr context;
int result = Rknn.InitModel(out context, "path_to_your_model.rknn");

进行推理

使用 Infer 方法进行模型推理:

List<RknnInput> inputs = new List<RknnInput>();
// 填充输入数据
List<RknnTensorAttr> attrs = new List<RknnTensorAttr>();
// 填充属性数据
List<DenseTensor<sbyte>> outputs = Rknn.Infer(context, inputs, attrs);

查询输入输出数量

使用 QueryInOut 方法查询模型的输入输出数量:

RknnInputOutputNum info;
int result = Rknn.QueryInOut(context, out info);

查询输出属性

使用 QueryOutAttr 方法查询模型输出的属性:

uint index = 0; // 输出索引
RknnTensorAttr attr;
int result = Rknn.QueryOutAttr(context, index, out attr);

加载和释放模型

使用 LoadModel 方法从文件加载模型:

string filePath = "path_to_your_model.rknn";
uint modelSize;
IntPtr modelPtr = Rknn.LoadModel(filePath, out modelSize);

使用 FreeModel 方法释放模型占用的内存:

Rknn.FreeModel(modelPtr);

示例

请参考项目中的示例代码了解如何使用 RknnToolkit.Net。

许可证

该项目使用 MIT 许可证。有关详细信息,请查看 LICENSE 文件。

贡献

如果您有任何建议或想要贡献代码,请随时提交 Pull Request 或创建 Issue。


请注意,以上 README.ms 文件是基于提供的项目脚本和原始 README.me 文件内容生成的。如果项目有更多的细节或特定的使用方法,您可能需要进一步补充 README.ms 文件。

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.6.1 146 1/2/2025
1.6.0 148 1/2/2025

1.6.0版本兼容