File ITensorFactory.hpp

Parent directory (DlSystem)

Definition (DlSystem/ITensorFactory.hpp)

Includes

Full File Listing

namespace DlSystem
class ITensorFactory
#include <ITensorFactory.hpp>

Public Functions

ITensorFactory()
std::unique_ptr<ITensor> createTensor(const TensorShape &shape) noexcept

Creates a new ITensor with uninitialized data.

The strides for the tensor will match the tensor dimensions (i.e., the tensor data is contiguous in memory).

Parameters

shape[in] The dimensions for the tensor in which the last element of the vector represents the fastest varying dimension and the zeroth element represents the slowest varying, etc.

Returns

A pointer to the created tensor or nullptr if creating failed.

std::unique_ptr<ITensor> createTensor(std::istream &input) noexcept = delete

Creates a new ITensor by loading it from a file.

Parameters

input[in] The input stream from which to read the tensor data.

Returns

A pointer to the created tensor or nullptr if creating failed.

std::unique_ptr<ITensor> createTensor(const TensorShape &shape, const unsigned char *data, size_t dataSize) noexcept

Create a new ITensor with specific data. (i.e. the tensor data is contiguous in memory). This tensor is primarily used to create a tensor where tensor size can’t be computed directly from dimension. One such example is NV21-formatted image, or any YUV formatted image.

Parameters
  • shape[in] The dimensions for the tensor in which the last element of the vector represents the fastest varying dimension and the zeroth element represents the slowest varying, etc.

  • data[in] The actual data with which the Tensor object is filled.

  • dataSize[in] The size of data

Returns

A pointer to the created tensor