infer(tensor, args)
Model(option, deviceId)
函数功能
用户可选择特定加载方式,加载推理模型。
输入参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| option | ModelLoadOptV2数据类型 | 用户可通过参数选择模型输入方式,具体请参见ModelLoadOptV2类。 |
| deviceId | int | 模型部署的芯片ID,默认为0号芯片。(-1表示模型部署在Host侧,为保留字段,请勿使用。) |
返回参数说明
返回模型对象。
父主题: Model类
infer(tensorList)
函数功能
通过输入Tensor列表进行模型推理。
输入参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| tensorList | List[base.Tensor] | Tensor列表。 |
返回参数说明
返回模型推理输出的List[base.Tensor]。
抛异常接口
分配Tensor内存失败及推理失败,抛出runtime异常。
父主题: Model类
infer(tensor, args)
函数功能
通过输入多个Tensor对象进行模型推理。
输入参数说明
参数名 | 类型 | 说明 |
|---|---|---|
tensor | Tensor对象 | 模型推理所需Tensor。 如需输入多个Tensor,请使用”,”以分隔形式传入,最大传入Tensor数量为1024。 |
args | 可变参数 |
返回参数说明
返回模型推理输出的List[base.Tensor]。
抛异常接口
参数校验失败,分配Tensor内存失败及推理失败,抛出runtime异常。
父主题: Model类
input_dtype(index)
函数功能
获得模型输入的对应Tensor的数据类型信息。
输入参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| index | int | 模型输入的索引(第index个输入)。 |
返回参数说明
返回输入Tensor的数据类型,base.dtype类型。
父主题: Model类
output_dtype(index)
函数功能
获得模型输出的对应Tensor的数据类型信息。
输入参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| index | int | 模型输出的索引(第index个输出)。 |
返回参数说明
返回输出Tensor的数据类型,base.dtype类型。
父主题: Model类
input_shape(index)
函数功能
获得模型输入的对应Tensor的数据shape信息。
输入参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| index | int | 模型输入的索引(第index个输入)。 |
返回参数说明
返回对应输入的Tensor的shape信息,List[int]类型。
父主题: Model类
在线提单