如何在Tensorflow Lite(实验C API)中创建输入张量并与解释器一起使用



如何使用C API在Tensorflow Lite中创建张量?然后,我们如何将它们与解释器一起使用?

我了解,Tensorflow Lite具有C API的文档,并且常规TensorFlow在CAPI上具有文档。但是,几乎没有关于使用C api进行精简版的信息。

Lite C API具有创建张量的功能,但我看不到CAPI标头文件中的任何地方(或Lite的任何其他相关标头/源文件(。

使用常规Tensorflow C API的示例中存在以下内容。但是它似乎不存在于TF Lite C API中。

TF_Tensor* input_tensor = tf_utils::CreateTensor(TF_FLOAT, input_dims.data(), input_dims.size(), input_vals.data(), input_vals.size() * sizeof(float));

TensorFlow Lite Tensors(TFL_Tensor(由解释器(TFL_Interpreter(实例所有,用户无法创建。您可以使用以下方法获取输入/输出张量的处理:

 TFL_Tensor* TFL_InterpreterGetInputTensor(
    const TFL_Interpreter* interpreter, int32_t input_index);
 const TFL_Tensor* TFL_InterpreterGetOutputTensor(
    const TFL_Interpreter* interpreter, int32_t output_index);

张量数据可以使用c_api.h标头中描述的方法读取(或更新(。由于这仍然是一个实验性的API,因此缺乏该文档,但我们希望在不久的将来将其移出实验。

最新更新