class dnnl::graph::tensor

Overview

A tensor object. More…

#include <dnnl_graph.hpp>

class tensor: public tensor_handle
{
public:
    // construction

    tensor();
    tensor(const logical_tensor& lt, const engine& aengine, void* handle);
    tensor(const logical_tensor& lt, const engine& aengine);

    // methods

    void* get_data_handle() const;
    void set_data_handle(void* handle);
    engine get_engine() const;
    logical_tensor get_logical_tensor() const;
};

Detailed Documentation

A tensor object.

Construction

tensor()

Default constructor. Constructs an empty object.

tensor(const logical_tensor& lt, const engine& aengine, void* handle)

Constructs a tensor object according to a given logical tensor, an engine, and a memory handle.

Parameters:

lt

The given logical tensor

aengine

Engine to store the data on.

handle

Handle of memory buffer to use as an underlying storage.

  • A pointer to the user-allocated buffer. In this case the library doesn’t own the buffer.

  • The DNNL_MEMORY_ALLOCATE special value. Instructs the library to allocate the buffer for the tensor. In this case the library owns the buffer.

  • DNNL_MEMORY_NONE to create tensor without an underlying buffer.

tensor(const logical_tensor& lt, const engine& aengine)

Constructs a tensor object.

The underlying buffer for the memory will be allocated by the library.

Parameters:

lt

The given logical tensor

aengine

Engine to store the data on.

Methods

void* get_data_handle() const

Returns the underlying memory buffer.

On the CPU engine, or when using USM, this is a pointer to the allocated memory.

void set_data_handle(void* handle)

Sets the underlying memory handle.

Parameters:

handle

Memory handle.

engine get_engine() const

Returns the associated engine.

Returns:

An engine object

logical_tensor get_logical_tensor() const

Returns the logical tensor of a tensor object.

Returns:

A logical_tensor object.