Tensor

class Tensor

Subclassed by ngraph::runtime::cpu::CPUTensorView, ngraph::runtime::dynamic::DynamicTensor, ngraph::runtime::gpu::GPUTensor, ngraph::runtime::HostTensor, ngraph::runtime::intelgpu::IntelGPUTensorView, ngraph::runtime::plaidml::PlaidML_Tensor

Public Functions

const Shape &get_shape() const

Get tensor shape.

Return
const reference to a Shape

const PartialShape &get_partial_shape() const

Get tensor partial shape.

Return
const reference to a PartialShape

Strides get_strides() const

Get tensor strides.

Return
Strides

const element::Type &get_element_type() const

Get tensor element type.

Return
element::Type

size_t get_element_count() const

Get number of elements in the tensor.

Return
number of elements in the tensor

size_t get_size_in_bytes() const

Get the size in bytes of the tensor.

Return
number of bytes in tensor’s allocation

const std::string &get_name() const

Get tensor’s unique name.

Return
tensor’s name

shared_ptr<descriptor::layout::TensorLayout> get_tensor_layout() const

Get tensor layout.

Return
tensor layout

void set_tensor_layout(const std::shared_ptr<descriptor::layout::TensorLayout> &layout)

Set tensor layout.

Parameters
  • layout: Layout to set

bool get_stale() const

Get the stale value of the tensor. A tensor is stale if its data is changed.

Return
true if there is new data in this tensor

void set_stale(bool val)

Set the stale value of the tensor. A tensor is stale if its data is changed.

virtual void write(const void *p, size_t n) = 0

Write bytes directly into the tensor.

Parameters
  • p: Pointer to source of data
  • n: Number of bytes to write, must be integral number of elements.

virtual void read(void *p, size_t n) const = 0

Read bytes directly from the tensor.

Parameters
  • p: Pointer to destination for data
  • n: Number of bytes to read, must be integral number of elements.

void copy_from(const ngraph::runtime::Tensor &source)

copy bytes directly from source to this tensor

Parameters
  • source: The source tensor

NGRAPH_DEPRECATED_DOC void ngraph::runtime::Tensor::write(const void * p, size_t offset, size_t n)

Write bytes directly into the tensor.

Parameters
  • p: Pointer to source of data
  • offset: Offset into tensor storage to begin writing. Must be element-aligned.
  • n: Number of bytes to write, must be integral number of elements.

NGRAPH_DEPRECATED_DOC void ngraph::runtime::Tensor::read(void * p, size_t offset, size_t n) const

Read bytes directly from the tensor.

Parameters
  • p: Pointer to destination for data
  • offset: Offset into tensor storage to begin writing. Must be element-aligned.
  • n: Number of bytes to read, must be integral number of elements.