DynamicBackend

class DynamicBackend : public ngraph::runtime::Backend

Wrapper class used to provide dynamic tensor support on backends that otherwise do not support dynamic tensors.

The main function of this class is to intercept create_dynamic_tensor and compile:

  • create_dynamic_tensor will return a special DynamicTensor object whose shape can be updated after creation. Internally, DynamicTensor wraps static tensors managed by the wrapped backend.
  • compile will return a special DynamicExecutable object, which allows dynamic shapes to be supported via graph cloning.

This class is instantiated by ngraph::runtime::Backend::create.

Public Functions

shared_ptr<runtime::Tensor> create_tensor(const element::Type &element_type, const Shape &shape, void *memory_pointer)

Create a tensor specific to this backend.

Return
shared_ptr to a new backend-specific tensor
Parameters
  • element_type: The type of the tensor element
  • shape: The shape of the tensor
  • memory_pointer: A pointer to a buffer used for this tensor. The size of the buffer must be sufficient to contain the tensor. The lifetime of the buffer is the responsibility of the caller.

shared_ptr<runtime::Tensor> create_tensor(const element::Type &element_type, const Shape &shape)

Create a tensor specific to this backend.

Return
shared_ptr to a new backend-specific tensor
Parameters
  • element_type: The type of the tensor element
  • shape: The shape of the tensor

std::shared_ptr<runtime::Tensor> create_dynamic_tensor(const element::Type &element_type, const PartialShape &shape)

Create a dynamic tensor specific to this backend, if the backend supports dynamic tensors.

Return
shared_ptr to a new backend-specific tensor
Parameters
  • element_type: The type of the tensor element
  • shape: The shape of the tensor
Exceptions
  • std::invalid_argument: if the backend does not support dynamic tensors

bool supports_dynamic_tensors()

Return
true if this backend supports dynamic tensors, else false.

shared_ptr<runtime::Executable> compile(std::shared_ptr<Function> func, bool enable_performance_data = false)

Compiles a Function.

Return
compiled function or nullptr on failure
Parameters
  • func: The function to compile