TF_AllocateTensor:最后一个“ len”参数是否多余?

时间:2019-11-26 10:04:40

标签: c tensorflow

tensorflow的C API提供了TF_AllocateTensor函数:

// Allocate and return a new Tensor.
//
// This function is an alternative to TF_NewTensor and should be used when
// memory is allocated to pass the Tensor to the C API. The allocated memory
// satisfies TensorFlow's memory alignment preferences and should be preferred
// over calling malloc and free.
//
// The caller must set the Tensor values by writing them to the pointer returned
// by TF_TensorData with length TF_TensorByteSize.
TF_CAPI_EXPORT extern TF_Tensor* TF_AllocateTensor(TF_DataType,
                                                   const int64_t* dims,
                                                   int num_dims, size_t len);

现在,C API的文档似乎仅包含标头注释,但是从我看到的使用此功能从代码片段中搜索的内容来看,为len提供的值始终等于{{1} }。

如果可以从其他参数推导出该参数,它有什么用?有一种用例,其中sizeof_data_type * prod(dims)可以是len以外的其他东西?

0 个答案:

没有答案