class ngraph::runtime::HostTensor

Overview

#include <host_tensor.hpp>

class HostTensor: public ngraph::runtime::Tensor
{
public:
    // construction

    HostTensor(
        const element::Type& element_type,
        const Shape& shape,
        void \* memory_pointer
        );

    HostTensor(const element::Type& element_type, const Shape& shape);
    HostTensor(const element::Type& element_type, const PartialShape& partial_shape);
    HostTensor();
    HostTensor(const Output<ov::Node>&);
    HostTensor(const std::shared_ptr<op::v0::Constant>& constant);

    // methods

    void initialize(const std::shared_ptr<op::v0::Constant>& constant);
    void \* get_data_ptr();
    const void \* get_data_ptr() const;

    template <typename T>
    T \* get_data_ptr();

    template <typename T>
    const T \* get_data_ptr() const;

    template <element::Type_t ET>
    element_type_traits<ET>::value_type \* get_data_ptr();

    template <element::Type_t ET>
    const element_type_traits<ET>::value_type \* get_data_ptr() const;

    virtual void write(const void \* p, size_t n);
    virtual void read(void \* p, size_t n) const;
    bool get_is_allocated() const;
    void set_element_type(const element::Type& element_type);
    void set_shape(const Shape& shape);
    void set_unary(const HostTensorPtr& arg);

    void set_broadcast(
        const op::AutoBroadcastSpec& autob,
        const HostTensorPtr& arg0,
        const HostTensorPtr& arg1
        );

    void set_broadcast(
        const op::AutoBroadcastSpec& autob,
        const HostTensorPtr& arg0,
        const HostTensorPtr& arg1,
        const element::Type& element_type
        );
};

Inherited Members

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;
    virtual void write(const void \* p, size_t n) = 0;
    virtual void read(void \* p, size_t n) const = 0;

Detailed Documentation

Methods

virtual void write(const void \* p, size_t n)

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

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 set_element_type(const element::Type& element_type)

Set the element type. Must be compatible with the current element type.

Parameters:

element_type

The element type

void set_shape(const Shape& shape)

Set the actual shape of the tensor compatibly with the partial shape.

Parameters:

shape

The shape being set

void set_unary(const HostTensorPtr& arg)

Set the shape of a node from an input.

Parameters:

arg

The input argument

void set_broadcast(
    const op::AutoBroadcastSpec& autob,
    const HostTensorPtr& arg0,
    const HostTensorPtr& arg1
    )

Set the shape of the tensor using broadcast rules.

Parameters:

autob

The broadcast mode

arg0

The first argument

arg1

The second argument

void set_broadcast(
    const op::AutoBroadcastSpec& autob,
    const HostTensorPtr& arg0,
    const HostTensorPtr& arg1,
    const element::Type& element_type
    )

Set the shape of the tensor using broadcast rules.

Parameters:

autob

The broadcast mode

arg0

The first argument

arg1

The second argument

element_type

The output element type