class ngraph::runtime::Tensor

Overview

#include <tensor.hpp>

class Tensor
{
public:
    // methods

    Tensor& operator = (const Tensor&);
    virtual const ngraph::Shape& get_shape() const;
    const ngraph::PartialShape& get_partial_shape() const;
    virtual const element::Type& get_element_type() const;
    virtual size_t get_element_count() const;
    virtual size_t get_size_in_bytes() const;
    const std::string& get_name() const;
    bool get_stale() const;
    void set_stale(bool val);
    virtual void write(const void* p, size_t n) = 0;
    virtual void read(void* p, size_t n) const = 0;
    virtual void wait_for_read_ready();
    virtual void wait_for_write_ready();
};

// direct descendants

class HostTensor;

Detailed Documentation

Methods

virtual const ngraph::Shape& get_shape() const

Get tensor shape.

Returns:

const reference to a Shape

const ngraph::PartialShape& get_partial_shape() const

Get tensor partial shape.

Returns:

const reference to a PartialShape

virtual const element::Type& get_element_type() const

Get tensor element type.

Returns:

element::Type

virtual size_t get_element_count() const

Get number of elements in the tensor.

Returns:

number of elements in the tensor

virtual size_t get_size_in_bytes() const

Get the size in bytes of the tensor.

Returns:

number of bytes in tensor’s allocation

const std::string& get_name() const

Get tensor’s unique name.

Returns:

tensor’s name

bool get_stale() const

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

Returns:

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.

virtual void wait_for_read_ready()

check tensor for new data, call may block. backends may use this to ensure tensor is updated (eg: lazy eval).

virtual void wait_for_write_ready()

notify tensor of new data, call may block. backends may use this as indication of new data in tensor.