# tensorflow::Tensor

`#include <tensor.h>`

Represents an n-dimensional array of values.

## Summary

| ### Constructors and Destructors ||
|---|---|
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1aebe57070a84f43b98e63671f52a117fe()` Creates a 1-dimensional, 0-element float tensor. ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a08e32d524ca560888c76a57e6fab5466(DataType type, const TensorShape & shape)` Creates a [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) of the given `type` and `shape`. ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1aec608b828b3807c153616598822fa555(Allocator *a, DataType type, const TensorShape & shape)` Creates a tensor with the input `type` and `shape`, using the allocator `a` to allocate the underlying buffer. ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a55de61e27b842b06b29c954b2c3bf3f3(Allocator *a, DataType type, const TensorShape & shape, const AllocationAttributes & allocation_attr)` Creates a tensor with the input `type` and `shape`, using the allocator `a` and the specified "allocation_attr" to allocate the underlying buffer. ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a306a1c30a4ed610837c775aed23f2a10(DataType type)` Creates an empty [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) of the given data type. ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1af8969ead84ed648963ae46e691547e9e(float scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a5d5e5d7b4a4177f7373b029131bc423b(double scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a6b512fe79a45e59d5fc5d7c3c70d5861(int32 scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ad6998eeb293c0556b7235130e4e30f28(uint32 scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a1fa38a7929a9c42f1e85bde0bbb8f8a6(uint16 scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ae4cca32e1273ab339a7c45644131f79d(uint8 scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a4170e596de9d00b51a90cccf9f52eb0e(int16 scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1af8dc1efcbaf688e76dd4c281f835895d(int8 scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ad257c8b06cffba75b885b2660bfc19ce(string scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ac4eebf0208aafd7bb871662330fa0164(complex64 scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a9d29b0abca4b31db30c0b10a9f9cbc5f(complex128 scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1af72aca91298a972787965e92c795cc13(int64 scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a1c765a977eb9cfd864586d7afa48a5f0(uint64 scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1aaf55b6346cd86757991d140d9f0708ad(bool scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ae82fabedfb3355965bfa6c950a4d0088(qint8 scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a709b3d5127f6daeae56ebe4231a4ff0b(quint8 scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1aa019552e7ea5d3f350b905829b0d5199(qint16 scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a418411132eecce8c0a526df8d7cceaeb(quint16 scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1af304024fec2e58bec0f93bea580d0be7(qint32 scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1acbf215151f87c2a19364f15bd69618ad(bfloat16 scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ab478fb0c62ce0e56a12f0812642bc16c(Eigen::half scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a473a4c38498e06f8e7d1125401cefdea(ResourceHandle scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a3da694b6697a62217d01b9c5a4ecfb3d(const char *scalar_value)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a6379ca55abf3e9f475a5fd0615d863d5(const https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor & other)` Copy constructor. ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a9ce0ef052f796ecaad68e2000853f339(https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor && other)` Move constructor. ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a212bdf999f5deef11504d781cf2ab855()` ||

| ### Public functions ||
|---|---|
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a3c21e0423f7577a32583eb96d2a3a5ec() const ` | `size_t` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a55198b51aab7ca4ef312416c2b742eec(TensorProto *proto) const ` | `void` Fills in `proto` with `*this` tensor's content. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a4b9855ed8179d0611e9bced54dfa3aad(TensorProto *proto) const ` | `void` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a76ab5c0e7b5f7dc9b12be46e02f9f957(const https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor & other, DataType dtype, const TensorShape & shape)` | `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/status#classtensorflow_1_1_status` Copy the other tensor into this tensor, reshape it and reinterpret the buffer's datatype. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1acf6199c97175185c91ccd350e8a6e19c(const https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor & other, const TensorShape & shape) TF_MUST_USE_RESULT` | `bool` Copy the other tensor into this tensor and reshape it. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a0810779554c95dd96718c5bba33243b5(int num_values) const ` | `string` A human-readable summary of the tensor suitable for debugging. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a5fbf54d5013d6aa9391d2c8e6314db66() const ` | `string` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a927fa44955ecb6173434fe1b77fd33bc() const ` | `string` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a04b83c98a70a80676c94fe1294faa6e1(TensorDescription *description) const ` | `void` Fill in the `TensorDescription` proto with metadata about the tensor that is useful for monitoring and debugging. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ad7cd0d781683c4cc7e66bd9e1da6fe57(const TensorProto & other) TF_MUST_USE_RESULT` | `bool` Parse `other` and construct the tensor. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1aea7f15d9d7432ee6ab82c8b1730ab804(Allocator *a, const TensorProto & other) TF_MUST_USE_RESULT` | `bool` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1aec1fa00d85d569b344a55ad89f915ce9() const ` | `bool` Returns true iff this tensor is aligned. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1aa44336c38c4baf3ed69f63aee131ba87() const ` | `bool` If necessary, has this [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) been initialized? |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a2e0df4f1c6996097c49822d112f0678f(const https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor & b) const ` | `bool` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a9dcfa39b1a721efeef32cf3692938a3a() const ` | `int64` Convenience accessor for the tensor shape. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a9b9acd3759bc39a23d4691816b2ba05c(const https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor & b) const ` | `bool` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a32360ef0267803a7b445226431b9656e(int64 dim0_start, int64 dim0_limit) const ` | `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor` Slice this tensor along the 1st dimension. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ae0fdb4677822b91cd516d810d0d35101(int64 index) const ` | `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor` Select a subslice from this tensor along the 1st dimension. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a696629b34ace203e8ac80af8b155755c(int64 max_entries, bool print_v2) const ` | `string` Render the first `max_entries` values in `*this` into a string. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ab2c0b13287edd6d8dec1bbc59794e81c() const ` | `size_t` Returns the estimated memory usage of this tensor. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a8fab7661ec78cfda7b02a85680070d20(const https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor & other, DataType dtype, const TensorShape & shape)` | `void` Like BitcastFrom, but CHECK fails if any preconditions are not met. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ab2ef54b27c9b0e944689220c665fe542(gtl::ArraySlice< int64 > new_sizes)` | `TTypes< T, NDIMS >::https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor` Return the tensor data to an `Eigen::Tensor` with the new shape specified in `new_sizes` and cast to a new dtype `T`. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a001008dcbf43f22c6fe1b3dae3038c7f(gtl::ArraySlice< int64 > new_sizes) const ` | `TTypes< T, NDIMS >::ConstTensor` Return the tensor data to an `Eigen::Tensor` with the new shape specified in `new_sizes` and cast to a new dtype `T`. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ab479fc449ce2e5da1a99d4cae8f6e47a()` | `TTypes< T, NDIMS >::https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor` Return the tensor data to an `Eigen::Tensor` with the same size but a bitwise cast to the specified dtype `T`. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1afced940422a1e726d9487cb3cb039630() const ` | `TTypes< T, NDIMS >::ConstTensor` Return the tensor data to an `Eigen::Tensor` with the same size but a bitwise cast to the specified dtype `T`. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1abe65a95f1db0afd36e0c6d32c752d988(int d) const ` | `int64` Convenience accessor for the tensor shape. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ac8a173cc6c97184139bfd81ff45e7da9() const ` | `int` Convenience accessor for the tensor shape. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a16a9c0fa93491bbc44377cd7eb58b3c6() const ` | `DataType` Returns the data type. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a67ce62becce1e70454d9756d1d5ed996()` | `TTypes< T >::Flat` Return the tensor data as an `Eigen::Tensor` of the data type and a specified shape. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1adfe83abc7c7b4834dc9d73ec3ec38f43() const ` | `TTypes< T >::ConstFlat` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a6f5bf51d9c7f2ebf21d56aa8313a8b5f()` | `TTypes< T, NDIMS >::https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor` Returns the data as an Eigen::Tensor with NDIMS dimensions, collapsing all [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) dimensions but the last NDIMS-1 into the first dimension of the result. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a2941fc6005d4f9e0197ffe478eac6bc6() const ` | `TTypes< T, NDIMS >::ConstTensor` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a46d643f84a81beb5b58e2bfb976516ee(int64 begin)` | `TTypes< T, NDIMS >::https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor` Returns the data as an Eigen::Tensor with NDIMS dimensions, collapsing the first 'begin' [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) dimensions into the first dimension of the result and the [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) dimensions of the last [dims()](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ac8a173cc6c97184139bfd81ff45e7da9) - 'begin' - NDIMS into the last dimension of the result. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ae2936e3a7b92f4545e13d4775ed105be(int64 begin) const ` | `TTypes< T, NDIMS >::ConstTensor` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a290876f00cea56107eeecc49af671c54()` | `TTypes< T, NDIMS >::https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor` Returns the data as an Eigen::Tensor with NDIMS dimensions, collapsing all [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) dimensions but the first NDIMS-1 into the last dimension of the result. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a49513c7e2fa9c4644760e0d579eb2607() const ` | `TTypes< T, NDIMS >::ConstTensor` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a6afab48885080a80ff0b52437959d929()` | `TTypes< T >::Matrix` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a4005578d5a8b62e0d6deb86569b6eb14() const ` | `TTypes< T >::ConstMatrix` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a6582b22e47d0ed025ba96698be491225(const https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor & other)` | `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor &` Assign operator. This tensor shares other's underlying storage. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ab1669f9097b60559467424f901bf3211(https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor && other)` | `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor &` Move operator. See move constructor for details. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a775ff735c4ec85176bc317f3d2f3e9f1()` | `TTypes< T, NDIMS >::https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor` Return the tensor data to an `Eigen::Tensor` with the last dimension elements converted into single elements of a larger type. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a1c1d8fcb22c6ce7aaefe98b28466a02f() const ` | `TTypes< T, NDIMS >::ConstTensor` Return the tensor data to an `Eigen::Tensor` with the last dimension elements converted into single elements of a larger type. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1aacce92855f6b83eea728203de8016c78()` | `TTypes< T >::Scalar` Return the [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) data as a `TensorMap` of fixed size 1: `TensorMap>`. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a6d20a479e87d6ef5af2c7f3364e22858() const ` | `TTypes< T >::ConstScalar` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ad0065facf49e31e4f48f07dd41528119() const ` | `const TensorShape &` Returns the shape of the tensor. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a4f6aa95ee286bd7d4134717fc9119b5a(gtl::ArraySlice< int64 > new_sizes)` | `TTypes< T, NDIMS >::https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ac701b1dc8f77a45caf3c34cd6b4f643d(gtl::ArraySlice< int64 > new_sizes) const ` | `TTypes< T, NDIMS >::ConstTensor` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1afd9dc3fa5b64e39221c72f8f6fe44769()` | `TTypes< T, NDIMS >::https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ac4f4bbc4c2dd1721e42481fe50c12735() const ` | `TTypes< T, NDIMS >::ConstTensor` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1aec0a1c04f8bc4c469453a0c13668b968() const ` | `StringPiece` Returns a `StringPiece` mapping the current tensor's buffer. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a93908c637764bdec8bfd08da5fe49a06()` | `TTypes< T >::UnalignedFlat` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a52f9619663d80a05a933d8ee96074b35() const ` | `TTypes< T >::UnalignedConstFlat` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a8f8085e2922ce769d26ccf75596e4a22(gtl::ArraySlice< int64 > new_sizes)` | `TTypes< T, NDIMS >::UnalignedTensor` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a5d466752fe3e44bd1570eb5ea673259c(gtl::ArraySlice< int64 > new_sizes) const ` | `TTypes< T, NDIMS >::UnalignedConstTensor` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a8714205b3a82f0338c53c31ee93eab95()` | `TTypes< T >::Vec` Return the tensor data as an `Eigen::Tensor` with the type and sizes of this `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor`. |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a0834fadcc0428f68c9d13bd32a1b20d9() const ` | `TTypes< T >::ConstVec` Const versions of all the methods above. |

## Public functions

### AllocatedBytes

```
size_t AllocatedBytes() const 
```

### AsProtoField

```
void AsProtoField(
  TensorProto *proto
) const 
```
Fills in `proto` with `*this` tensor's content.

`https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a55198b51aab7ca4ef312416c2b742eec` fills in the repeated field for `proto.dtype()`, while `AsProtoTensorContent()` encodes the content in `proto.tensor_content()` in a compact form.

### AsProtoTensorContent

```
void AsProtoTensorContent(
  TensorProto *proto
) const 
```

### BitcastFrom

```
Status BitcastFrom(
  const Tensor & other,
  DataType dtype,
  const TensorShape & shape
)
```
Copy the other tensor into this tensor, reshape it and reinterpret the buffer's datatype.

If Status::OK() is returned, the two tensors now share the same underlying storage.

This call requires that the `other` tensor and the given type and shape are "compatible" (i.e. they occupy the same number of bytes).

Specifically:

shape.num_elements() \* DataTypeSize(type)

must equal

other.num_elements() \* DataTypeSize(other.dtype())

In addition, this function requires:

- DataTypeSize(other.dtype()) != 0
- DataTypeSize(type) != 0

<br />

If any of the requirements are not met, errors::InvalidArgument is returned.

### CopyFrom

```
bool CopyFrom(
  const Tensor & other,
  const TensorShape & shape
) TF_MUST_USE_RESULT
```
Copy the other tensor into this tensor and reshape it.

This tensor shares other's underlying storage. Returns `true` iff `other.shape()` has the same number of elements of the given `shape`.

### DebugString

```
string DebugString(
  int num_values
) const 
```
A human-readable summary of the tensor suitable for debugging.

### DebugString

```
string DebugString() const 
```

### DeviceSafeDebugString

```
string DeviceSafeDebugString() const 
```

### FillDescription

```
void FillDescription(
  TensorDescription *description
) const 
```
Fill in the `TensorDescription` proto with metadata about the tensor that is useful for monitoring and debugging.

### FromProto

```
bool FromProto(
  const TensorProto & other
) TF_MUST_USE_RESULT
```
Parse `other` and construct the tensor.

Returns `true` iff the parsing succeeds. If the parsing fails, the state of `*this` is unchanged.

### FromProto

```
bool FromProto(
  Allocator *a,
  const TensorProto & other
) TF_MUST_USE_RESULT
```

### IsAligned

```
bool IsAligned() const 
```
Returns true iff this tensor is aligned.

### IsInitialized

```
bool IsInitialized() const 
```
If necessary, has this [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) been initialized?

Zero-element Tensors are always considered initialized, even if they have never been assigned to and do not have any memory allocated.

### IsSameSize

```
bool IsSameSize(
  const Tensor & b
) const 
```

### NumElements

```
int64 NumElements() const 
```
Convenience accessor for the tensor shape.

### SharesBufferWith

```
bool SharesBufferWith(
  const Tensor & b
) const 
```

### Slice

```
Tensor Slice(
  int64 dim0_start,
  int64 dim0_limit
) const 
```
Slice this tensor along the 1st dimension.

I.e., the returned tensor satisfies returned\[i, ...\] == this\[dim0_start + i, ...\]. The returned tensor shares the underlying tensor buffer with this tensor.

NOTE: The returned tensor may not satisfy the same alignment requirement as this tensor depending on the shape. The caller must check the returned tensor's alignment before calling certain methods that have alignment requirement (e.g., `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a67ce62becce1e70454d9756d1d5ed996`, `tensor()`).

NOTE: When fed with an N-dimensional tensor, this method returns a tensor also with N dimensions. If you want to select a sub tensor, see SubSlice.

REQUIRES: `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ac8a173cc6c97184139bfd81ff45e7da9` \>= 1 REQUIRES: `0 <= dim0_start <= dim0_limit <= dim_size(0)`

### SubSlice

```
Tensor SubSlice(
  int64 index
) const 
```
Select a subslice from this tensor along the 1st dimension.

When fed with an N-dimensional tensor, this method returns a tensor with N-1 dimensions, where the returned tensor is a subslice of the input tensor along the first dimension. The N-1 dimensions of the returned tensor are the last N-1 dimensions of the input tensor.

NOTE: The returned tensor may not satisfy the same alignment requirement as this tensor depending on the shape. The caller must check the returned tensor's alignment before calling certain methods that have alignment requirement (e.g., `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a67ce62becce1e70454d9756d1d5ed996`, `tensor()`).

REQUIRES: `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ac8a173cc6c97184139bfd81ff45e7da9` \>= 1 REQUIRES: `0 <= dim0_start < dim_size(0)`

### SummarizeValue

```
string SummarizeValue(
  int64 max_entries,
  bool print_v2
) const 
```
Render the first `max_entries` values in `*this` into a string.

### Tensor

```
 Tensor()
```
Creates a 1-dimensional, 0-element float tensor.

The returned [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) is not a scalar (shape {}), but is instead an empty one-dimensional [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) (shape {0}, [NumElements()](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1a9dcfa39b1a721efeef32cf3692938a3a) == 0). Since it has no elements, it does not need to be assigned a value and is initialized by default ([IsInitialized()](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1aa44336c38c4baf3ed69f63aee131ba87) is true). If this is undesirable, consider creating a one-element scalar which does require initialization:


```
Tensor(DT_FLOAT, TensorShape({}))
```

<br />


```

```

### Tensor

```
 Tensor(
  DataType type,
  const TensorShape & shape
)
```
Creates a [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) of the given `type` and `shape`.

If LogMemory::IsEnabled() the allocation is logged as coming from an unknown kernel and step. Calling the [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) constructor directly from within an Op is deprecated: use the OpKernelConstruction/OpKernelContext allocate_\* methods to allocate a new tensor, which record the kernel and step.

The underlying buffer is allocated using a `CPUAllocator`.

### Tensor

```
 Tensor(
  Allocator *a,
  DataType type,
  const TensorShape & shape
)
```
Creates a tensor with the input `type` and `shape`, using the allocator `a` to allocate the underlying buffer.

If LogMemory::IsEnabled() the allocation is logged as coming from an unknown kernel and step. Calling the [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) constructor directly from within an Op is deprecated: use the OpKernelConstruction/OpKernelContext allocate_\* methods to allocate a new tensor, which record the kernel and step.

`a` must outlive the lifetime of this [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor).

### Tensor

```
 Tensor(
  Allocator *a,
  DataType type,
  const TensorShape & shape,
  const AllocationAttributes & allocation_attr
)
```
Creates a tensor with the input `type` and `shape`, using the allocator `a` and the specified "allocation_attr" to allocate the underlying buffer.

If the kernel and step are known allocation_attr.allocation_will_be_logged should be set to true and LogMemory::RecordTensorAllocation should be called after the tensor is constructed. Calling the [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) constructor directly from within an Op is deprecated: use the OpKernelConstruction/OpKernelContext allocate_\* methods to allocate a new tensor, which record the kernel and step.

`a` must outlive the lifetime of this [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor).

### Tensor

```
 Tensor(
  DataType type
)
```
Creates an empty [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) of the given data type.

Like [Tensor()](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1aebe57070a84f43b98e63671f52a117fe), returns a 1-dimensional, 0-element [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) with [IsInitialized()](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1aa44336c38c4baf3ed69f63aee131ba87) returning True. See the [Tensor()](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1aebe57070a84f43b98e63671f52a117fe) documentation for details.

### Tensor

```
 Tensor(
  float scalar_value
)
```

### Tensor

```
 Tensor(
  double scalar_value
)
```

### Tensor

```
 Tensor(
  int32 scalar_value
)
```

### Tensor

```
 Tensor(
  uint32 scalar_value
)
```

### Tensor

```
 Tensor(
  uint16 scalar_value
)
```

### Tensor

```
 Tensor(
  uint8 scalar_value
)
```

### Tensor

```
 Tensor(
  int16 scalar_value
)
```

### Tensor

```
 Tensor(
  int8 scalar_value
)
```

### Tensor

```
 Tensor(
  string scalar_value
)
```

### Tensor

```
 Tensor(
  complex64 scalar_value
)
```

### Tensor

```
 Tensor(
  complex128 scalar_value
)
```

### Tensor

```
 Tensor(
  int64 scalar_value
)
```

### Tensor

```
 Tensor(
  uint64 scalar_value
)
```

### Tensor

```
 Tensor(
  bool scalar_value
)
```

### Tensor

```
 Tensor(
  qint8 scalar_value
)
```

### Tensor

```
 Tensor(
  quint8 scalar_value
)
```

### Tensor

```
 Tensor(
  qint16 scalar_value
)
```

### Tensor

```
 Tensor(
  quint16 scalar_value
)
```

### Tensor

```
 Tensor(
  qint32 scalar_value
)
```

### Tensor

```
 Tensor(
  bfloat16 scalar_value
)
```

### Tensor

```
 Tensor(
  Eigen::half scalar_value
)
```

### Tensor

```
 Tensor(
  ResourceHandle scalar_value
)
```

### Tensor

```
 Tensor(
  const char *scalar_value
)
```

### Tensor

```
 Tensor(
  const Tensor & other
)
```
Copy constructor.

### Tensor

```
 Tensor(
  Tensor && other
)
```
Move constructor.

After this call, is safely destructible and can be assigned to, but other calls on it (e.g. shape manipulation) are not valid.

### TotalBytes

```
size_t TotalBytes() const 
```
Returns the estimated memory usage of this tensor.

### UnsafeCopyFromInternal

```
void UnsafeCopyFromInternal(
  const Tensor & other,
  DataType dtype,
  const TensorShape & shape
)
```
Like BitcastFrom, but CHECK fails if any preconditions are not met.

Deprecated. Use BitcastFrom instead and check the returned [Status](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/status#classtensorflow_1_1_status).

### bit_casted_shaped

```
TTypes< T, NDIMS >::Tensor bit_casted_shaped(
  gtl::ArraySlice< int64 > new_sizes
)
```
Return the tensor data to an `Eigen::Tensor` with the new shape specified in `new_sizes` and cast to a new dtype `T`.

Using a bitcast is useful for move and copy operations. The allowed bitcast is the only difference from `shaped()`.

### bit_casted_shaped

```
TTypes< T, NDIMS >::ConstTensor bit_casted_shaped(
  gtl::ArraySlice< int64 > new_sizes
) const 
```
Return the tensor data to an `Eigen::Tensor` with the new shape specified in `new_sizes` and cast to a new dtype `T`.

Using a bitcast is useful for move and copy operations. The allowed bitcast is the only difference from `shaped()`.

### bit_casted_tensor

```
TTypes< T, NDIMS >::Tensor bit_casted_tensor()
```
Return the tensor data to an `Eigen::Tensor` with the same size but a bitwise cast to the specified dtype `T`.

Using a bitcast is useful for move and copy operations. NOTE: this is the same as `tensor()` except a bitcast is allowed.

### bit_casted_tensor

```
TTypes< T, NDIMS >::ConstTensor bit_casted_tensor() const 
```
Return the tensor data to an `Eigen::Tensor` with the same size but a bitwise cast to the specified dtype `T`.

Using a bitcast is useful for move and copy operations. NOTE: this is the same as `tensor()` except a bitcast is allowed.

### dim_size

```
int64 dim_size(
  int d
) const 
```
Convenience accessor for the tensor shape.

### dims

```
int dims() const 
```
Convenience accessor for the tensor shape.

For all shape accessors, see comments for relevant methods of `TensorShape` in `tensor_shape.h`.

### dtype

```
DataType dtype() const 
```
Returns the data type.

### flat

```
TTypes< T >::Flat flat()
```
Return the tensor data as an `Eigen::Tensor` of the data type and a specified shape.

These methods allow you to access the data with the dimensions and sizes of your choice. You do not need to know the number of dimensions of the [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) to call them. However, they `CHECK` that the type matches and the dimensions requested creates an `Eigen::Tensor` with the same number of elements as the tensor.

Example:


```
  
    typedef float T;
    Tensor my_ten(...built with Shape{planes: 4, rows: 3, cols: 5}...);
    // 1D Eigen::Tensor, size 60:
    auto flat = my_ten.flat();
    // 2D Eigen::Tensor 12 x 5:
    auto inner = my_ten.flat_inner_dims();
    // 2D Eigen::Tensor 4 x 15:
    auto outer = my_ten.shaped<T, 2>({4, 15});
    // CHECK fails, bad num elements:
    auto outer = my_ten.shaped<T, 2>({4, 8});
    // 3D Eigen::Tensor 6 x 5 x 2:
    auto weird = my_ten.shaped<T, 3>({6, 5, 2});
    // CHECK fails, type mismatch:
    auto bad   = my_ten.flat();
```

<br />


```

```

### flat

```
TTypes< T >::ConstFlat flat() const 
```

### flat_inner_dims

```
TTypes< T, NDIMS >::Tensor flat_inner_dims()
```
Returns the data as an Eigen::Tensor with NDIMS dimensions, collapsing all [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) dimensions but the last NDIMS-1 into the first dimension of the result.

If NDIMS \> [dims()](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ac8a173cc6c97184139bfd81ff45e7da9) then leading dimensions of size 1 will be added to make the output rank NDIMS.

### flat_inner_dims

```
TTypes< T, NDIMS >::ConstTensor flat_inner_dims() const 
```

### flat_inner_outer_dims

```
TTypes< T, NDIMS >::Tensor flat_inner_outer_dims(
  int64 begin
)
```
Returns the data as an Eigen::Tensor with NDIMS dimensions, collapsing the first 'begin' [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) dimensions into the first dimension of the result and the [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) dimensions of the last [dims()](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ac8a173cc6c97184139bfd81ff45e7da9) - 'begin' - NDIMS into the last dimension of the result.

If 'begin' \< 0 then the \|'begin'\| leading dimensions of size 1 will be added. If 'begin' + NDIMS \> [dims()](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ac8a173cc6c97184139bfd81ff45e7da9) then 'begin' + NDIMS - [dims()](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ac8a173cc6c97184139bfd81ff45e7da9) trailing dimensions of size 1 will be added.

### flat_inner_outer_dims

```
TTypes< T, NDIMS >::ConstTensor flat_inner_outer_dims(
  int64 begin
) const 
```

### flat_outer_dims

```
TTypes< T, NDIMS >::Tensor flat_outer_dims()
```
Returns the data as an Eigen::Tensor with NDIMS dimensions, collapsing all [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) dimensions but the first NDIMS-1 into the last dimension of the result.

If NDIMS \> [dims()](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1ac8a173cc6c97184139bfd81ff45e7da9) then trailing dimensions of size 1 will be added to make the output rank NDIMS.

### flat_outer_dims

```
TTypes< T, NDIMS >::ConstTensor flat_outer_dims() const 
```

### matrix

```
TTypes< T >::Matrix matrix()
```

### matrix

```
TTypes< T >::ConstMatrix matrix() const 
```

### operator=

```
Tensor & operator=(
  const Tensor & other
)
```
Assign operator. This tensor shares other's underlying storage.

### operator=

```
Tensor & operator=(
  Tensor && other
)
```
Move operator. See move constructor for details.

### reinterpret_last_dimension

```
TTypes< T, NDIMS >::Tensor reinterpret_last_dimension()
```
Return the tensor data to an `Eigen::Tensor` with the last dimension elements converted into single elements of a larger type.

For example, this is useful for kernels that can treat NCHW_VECT_C int8 tensors as NCHW int32 tensors. The sizeof(T) should equal the size of the original element type \* num elements in the original last dimension. NDIMS should be 1 less than the original number of dimensions.

### reinterpret_last_dimension

```
TTypes< T, NDIMS >::ConstTensor reinterpret_last_dimension() const 
```
Return the tensor data to an `Eigen::Tensor` with the last dimension elements converted into single elements of a larger type.

For example, this is useful for kernels that can treat NCHW_VECT_C int8 tensors as NCHW int32 tensors. The sizeof(T) should equal the size of the original element type \* num elements in the original last dimension. NDIMS should be 1 less than the original number of dimensions.

### scalar

```
TTypes< T >::Scalar scalar()
```
Return the [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) data as a `TensorMap` of fixed size 1: `TensorMap>`.

Using `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor_1aacce92855f6b83eea728203de8016c78` allows the compiler to perform optimizations as the size of the tensor is known at compile time.

### scalar

```
TTypes< T >::ConstScalar scalar() const 
```

### shape

```
const TensorShape & shape() const 
```
Returns the shape of the tensor.

### shaped

```
TTypes< T, NDIMS >::Tensor shaped(
  gtl::ArraySlice< int64 > new_sizes
)
```

### shaped

```
TTypes< T, NDIMS >::ConstTensor shaped(
  gtl::ArraySlice< int64 > new_sizes
) const 
```

### tensor

```
TTypes< T, NDIMS >::Tensor tensor()
```

### tensor

```
TTypes< T, NDIMS >::ConstTensor tensor() const 
```

### tensor_data

```
StringPiece tensor_data() const 
```
Returns a `StringPiece` mapping the current tensor's buffer.

The returned `StringPiece` may point to memory location on devices that the CPU cannot address directly.

NOTE: The underlying tensor buffer is refcounted, so the lifetime of the contents mapped by the `StringPiece` matches the lifetime of the buffer; callers should arrange to make sure the buffer does not get destroyed while the `StringPiece` is still used.

REQUIRES: `DataTypeCanUseMemcpy(dtype())`.

### unaligned_flat

```
TTypes< T >::UnalignedFlat unaligned_flat()
```

### unaligned_flat

```
TTypes< T >::UnalignedConstFlat unaligned_flat() const 
```

### unaligned_shaped

```
TTypes< T, NDIMS >::UnalignedTensor unaligned_shaped(
  gtl::ArraySlice< int64 > new_sizes
)
```

### unaligned_shaped

```
TTypes< T, NDIMS >::UnalignedConstTensor unaligned_shaped(
  gtl::ArraySlice< int64 > new_sizes
) const 
```

### vec

```
TTypes< T >::Vec vec()
```
Return the tensor data as an `Eigen::Tensor` with the type and sizes of this `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor`.

Use these methods when you know the data type and the number of dimensions of the [Tensor](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) and you want an `Eigen::Tensor` automatically sized to the `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor` sizes. The implementation check fails if either type or sizes mismatch.

Example:


```
  
    typedef float T;
    Tensor my_mat(...built with Shape{rows: 3, cols: 5}...);
    auto mat = my_mat.matrix();    // 2D Eigen::Tensor, 3 x 5.
    auto mat = my_mat.tensor<T, 2>(); // 2D Eigen::Tensor, 3 x 5.
    auto vec = my_mat.vec();       // CHECK fails as my_mat is 2D.
    auto vec = my_mat.tensor<T, 3>(); // CHECK fails as my_mat is 2D.
    auto mat = my_mat.matrix();// CHECK fails as type mismatch.
```

<br />


```

```

### vec

```
TTypes< T >::ConstVec vec() const 
```
Const versions of all the methods above.

### \~Tensor

```
 ~Tensor()
```