.. index:: pair: class; dnnl::graph::tensor .. _doxid-classdnnl_1_1graph_1_1tensor: class dnnl::graph::tensor ========================= .. toctree:: :hidden: Overview ~~~~~~~~ A tensor object. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class tensor: public tensor_handle { public: // construction :ref:`tensor`(); :ref:`tensor`(const :ref:`logical_tensor`& lt, const :ref:`engine`& aengine, void* handle); :ref:`tensor`(const :ref:`logical_tensor`& lt, const :ref:`engine`& aengine); // methods void* :ref:`get_data_handle`() const; void :ref:`set_data_handle`(void* handle); :ref:`engine` :ref:`get_engine`() const; }; .. _details-classdnnl_1_1graph_1_1tensor: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ A tensor object. Construction ------------ .. index:: pair: function; tensor .. _doxid-classdnnl_1_1graph_1_1tensor_1a73b101ca2e1c7766b170f611041acbb0: .. ref-code-block:: cpp :class: doxyrest-title-code-block tensor() Default constructor. Constructs an empty object. .. index:: pair: function; tensor .. _doxid-classdnnl_1_1graph_1_1tensor_1a14bd0ec6d331f29750cb68257983a790: .. ref-code-block:: cpp :class: doxyrest-title-code-block tensor(const :ref:`logical_tensor`& lt, const :ref:`engine`& aengine, void* handle) Constructs a tensor object according to a given logical tensor, an engine, and a memory handle. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - 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. .. index:: pair: function; tensor .. _doxid-classdnnl_1_1graph_1_1tensor_1ac92d367612161648cdc32f975b78f716: .. ref-code-block:: cpp :class: doxyrest-title-code-block tensor(const :ref:`logical_tensor`& lt, const :ref:`engine`& aengine) Constructs a tensor object. The underlying buffer for the memory will be allocated by the library. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - lt - The given logical tensor * - aengine - Engine to store the data on. Methods ------- .. index:: pair: function; get_data_handle .. _doxid-classdnnl_1_1graph_1_1tensor_1aee1d338d718fb36fa6acc87d0373663e: .. ref-code-block:: cpp :class: doxyrest-title-code-block 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. .. index:: pair: function; set_data_handle .. _doxid-classdnnl_1_1graph_1_1tensor_1a5162eaf95542798d834bd8899138166e: .. ref-code-block:: cpp :class: doxyrest-title-code-block void set_data_handle(void* handle) Sets the underlying memory handle. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - handle - Memory handle. .. index:: pair: function; get_engine .. _doxid-classdnnl_1_1graph_1_1tensor_1a588455c7eed8230723445b9dba997fb5: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`engine` get_engine() const Returns the associated engine. .. rubric:: Returns: An engine object