टेंसरफ़्लो:: टेन्सर

#include <tensor.h>

मानों की एक एन-आयामी सरणी का प्रतिनिधित्व करता है।

सारांश

निर्माता और विध्वंसक

Tensor ()
एक 1-आयामी, 0-तत्व फ्लोट टेंसर बनाता है।
Tensor (DataType type, const TensorShape & shape)
दिए गए type और shape का एक टेंसर बनाता है।
Tensor (Allocator *a, DataType type, const TensorShape & shape)
अंतर्निहित बफ़र को आवंटित करने के लिए एलोकेटर का उपयोग करके इनपुट type और shape a साथ एक टेंसर बनाता है।
Tensor (Allocator *a, DataType type, const TensorShape & shape, const AllocationAttributes & allocation_attr)
अंतर्निहित बफ़र को आवंटित करने के लिए एलोकेटर a और निर्दिष्ट "allocation_attr" का उपयोग करके इनपुट type और shape के साथ एक टेंसर बनाता है।
Tensor (DataType type, const TensorShape & shape, TensorBuffer *buf)
इनपुट डेटाटाइप, आकार और buf के साथ एक टेंसर बनाता है।
Tensor (DataType type)
दिए गए डेटा प्रकार का एक खाली टेंसर बनाता है।
Tensor (float scalar_value)
Tensor (double scalar_value)
Tensor (int32 scalar_value)
Tensor (uint32 scalar_value)
Tensor (uint16 scalar_value)
Tensor (uint8 scalar_value)
Tensor (int16 scalar_value)
Tensor (int8 scalar_value)
Tensor (tstring scalar_value)
Tensor (complex64 scalar_value)
Tensor (complex128 scalar_value)
Tensor (int64 scalar_value)
Tensor (uint64 scalar_value)
Tensor (bool scalar_value)
Tensor (qint8 scalar_value)
Tensor (quint8 scalar_value)
Tensor (qint16 scalar_value)
Tensor (quint16 scalar_value)
Tensor (qint32 scalar_value)
Tensor (bfloat16 scalar_value)
Tensor (Eigen::half scalar_value)
Tensor (ResourceHandle scalar_value)
Tensor (const char *scalar_value)
Tensor (const Tensor & other)
कंस्ट्रक्टर कॉपी करें.
Tensor ( Tensor && other)
कंस्ट्रक्टर को स्थानांतरित करें।
~Tensor ()

सार्वजनिक समारोह

AllocatedBytes () const
size_t
AsProtoField (TensorProto *proto) const
void
proto को *this टेंसर की सामग्री से भरता है।
AsProtoTensorContent (TensorProto *proto) const
void
BitcastFrom (const Tensor & other, DataType dtype, const TensorShape & shape)
अन्य टेंसर को इस टेंसर में कॉपी करें, इसे दोबारा आकार दें और बफ़र के डेटाटाइप की दोबारा व्याख्या करें।
CopyFrom (const Tensor & other, const TensorShape & shape) TF_MUST_USE_RESULT
bool
अन्य टेंसर को इस टेंसर में कॉपी करें और इसे नया आकार दें।
DebugString (int num_values) const
string
डिबगिंग के लिए उपयुक्त टेंसर का मानव-पठनीय सारांश।
DebugString () const
string
DeviceSafeDebugString () const
string
FillDescription (TensorDescription *description) const
void
TensorDescription प्रोटो को टेंसर के बारे में मेटाडेटा के साथ भरें जो मॉनिटरिंग और डिबगिंग के लिए उपयोगी है।
FromProto (const TensorProto & other) TF_MUST_USE_RESULT
bool
other पार्स करें और टेंसर का निर्माण करें।
FromProto (Allocator *a, const TensorProto & other) TF_MUST_USE_RESULT
bool
IsAligned () const
bool
यदि यह टेंसर संरेखित है तो सत्य लौटाता है।
IsInitialized () const
bool
यदि आवश्यक हो, तो क्या इस टेंसर को आरंभीकृत किया गया है?
IsSameSize (const Tensor & b) const
bool
NumElements () const
int64
टेंसर आकार के लिए सुविधा सहायक।
SharesBufferWith (const Tensor & b) const
bool
Slice (int64 dim0_start, int64 dim0_limit) const
इस टेंसर को पहले आयाम के साथ काटें।
SubSlice (int64 index) const
पहले आयाम के साथ इस टेंसर से एक उपस्लाइस का चयन करें।
SummarizeValue (int64 max_entries, bool print_v2) const
string
*this में पहले max_entries मानों को एक स्ट्रिंग में प्रस्तुत करें।
TotalBytes () const
size_t
इस टेंसर का अनुमानित मेमोरी उपयोग लौटाता है।
UnsafeCopyFromInternal (const Tensor & other, DataType dtype, const TensorShape & shape)
void
BitcastFrom की तरह, लेकिन यदि कोई पूर्व शर्त पूरी नहीं होती है तो CHECK विफल हो जाता है।
bit_casted_shaped (gtl::ArraySlice< int64 > new_sizes)
TTypes< T, NDIMS >:: Tensor
टेंसर डेटा को new_sizes में निर्दिष्ट नए आकार के साथ Eigen::Tensor पर लौटाएं और एक नए dtype T पर डालें।
bit_casted_shaped (gtl::ArraySlice< int64 > new_sizes) const
TTypes< T, NDIMS >::ConstTensor
टेंसर डेटा को new_sizes में निर्दिष्ट नए आकार के साथ Eigen::Tensor पर लौटाएं और एक नए dtype T पर डालें।
bit_casted_tensor ()
TTypes< T, NDIMS >:: Tensor
टेंसर डेटा को समान आकार वाले Eigen::Tensor पर लौटाएं लेकिन निर्दिष्ट dtype T पर बिटवाइज़ कास्ट करें।
bit_casted_tensor () const
TTypes< T, NDIMS >::ConstTensor
टेंसर डेटा को समान आकार वाले Eigen::Tensor पर लौटाएं लेकिन निर्दिष्ट dtype T पर बिटवाइज़ कास्ट करें।
dim_size (int d) const
int64
टेंसर आकार के लिए सुविधा सहायक।
dims () const
int
टेंसर आकार के लिए सुविधा सहायक।
dtype () const
DataType
डेटा प्रकार लौटाता है.
flat ()
TTypes< T >::Flat
टेंसर डेटा को डेटा प्रकार और एक निर्दिष्ट आकार के Eigen::Tensor के रूप में लौटाएँ।
flat () const
TTypes< T >::ConstFlat
flat_inner_dims ()
TTypes< T, NDIMS >:: Tensor
डेटा को NDIMS आयामों के साथ Eigen::Tensor के रूप में लौटाता है, अंतिम NDIMS-1 को छोड़कर सभी Tensor आयामों को परिणाम के पहले आयाम में संक्षिप्त करता है।
flat_inner_dims () const
TTypes< T, NDIMS >::ConstTensor
flat_inner_outer_dims (int64 begin)
TTypes< T, NDIMS >:: Tensor
डेटा को NDIMS आयामों के साथ Eigen::Tensor के रूप में लौटाता है, पहले 'प्रारंभ' Tensor आयामों को परिणाम के पहले आयाम में और अंतिम dims() - 'begin' - NDIMS के Tensor आयामों को अंतिम आयाम में संक्षिप्त करता है। परिणाम।
flat_inner_outer_dims (int64 begin) const
TTypes< T, NDIMS >::ConstTensor
flat_outer_dims ()
TTypes< T, NDIMS >:: Tensor
डेटा को NDIMS आयामों के साथ Eigen::Tensor के रूप में लौटाता है, परिणाम के अंतिम आयाम में पहले NDIMS-1 को छोड़कर सभी Tensor आयामों को संक्षिप्त करता है।
flat_outer_dims () const
TTypes< T, NDIMS >::ConstTensor
matrix ()
TTypes< T >::Matrix
matrix () const
TTypes< T >::ConstMatrix
operator= (const Tensor & other)
ऑपरेटर नियुक्त करें. यह टेंसर दूसरे के अंतर्निहित भंडारण को साझा करता है।
operator= ( Tensor && other)
ऑपरेटर ले जाएँ. विवरण के लिए मूव कंस्ट्रक्टर देखें।
reinterpret_last_dimension ()
TTypes< T, NDIMS >:: Tensor
टेंसर डेटा को Eigen::Tensor पर लौटाएं, जिसमें अंतिम आयाम वाले तत्व बड़े प्रकार के एकल तत्वों में परिवर्तित हो जाएं।
reinterpret_last_dimension () const
TTypes< T, NDIMS >::ConstTensor
टेंसर डेटा को Eigen::Tensor पर लौटाएं, जिसमें अंतिम आयाम वाले तत्व बड़े प्रकार के एकल तत्वों में परिवर्तित हो जाएं।
scalar ()
TTypes< T >::Scalar
Tensor डेटा को निश्चित आकार 1 के TensorMap के रूप में लौटाएँ: TensorMap > TensorMap > .
scalar () const
TTypes< T >::ConstScalar
shape () const
const TensorShape &
टेंसर का आकार लौटाता है.
shaped (gtl::ArraySlice< int64 > new_sizes)
TTypes< T, NDIMS >:: Tensor
shaped (gtl::ArraySlice< int64 > new_sizes) const
TTypes< T, NDIMS >::ConstTensor
tensor ()
TTypes< T, NDIMS >:: Tensor
tensor () const
TTypes< T, NDIMS >::ConstTensor
tensor_data () const
StringPiece
वर्तमान टेंसर के बफ़र को मैप करते हुए एक StringPiece लौटाता है।
unaligned_flat ()
TTypes< T >::UnalignedFlat
unaligned_flat () const
TTypes< T >::UnalignedConstFlat
unaligned_shaped (gtl::ArraySlice< int64 > new_sizes)
TTypes< T, NDIMS >::UnalignedTensor
unaligned_shaped (gtl::ArraySlice< int64 > new_sizes) const
TTypes< T, NDIMS >::UnalignedConstTensor
vec ()
TTypes< T >::Vec
इस Tensor के प्रकार और आकार के साथ Tensor डेटा को Eigen::Tensor के रूप में लौटाएं।
vec () const
TTypes< T >::ConstVec
उपरोक्त सभी विधियों के कॉन्स्ट संस्करण।

सार्वजनिक समारोह

आवंटित बाइट्स

size_t AllocatedBytes() const 

AsProtoField

void AsProtoField(
  TensorProto *proto
) const 

proto को *this टेंसर की सामग्री से भरता है।

AsProtoField() proto.dtype() के लिए दोहराए गए फ़ील्ड को भरता है, जबकि AsProtoTensorContent() सामग्री को proto.tensor_content() में एक कॉम्पैक्ट रूप में एन्कोड करता है।

AsProtoTensorContent

void AsProtoTensorContent(
  TensorProto *proto
) const 

BitcastFrom

Status BitcastFrom(
  const Tensor & other,
  DataType dtype,
  const TensorShape & shape
)

अन्य टेंसर को इस टेंसर में कॉपी करें, इसे दोबारा आकार दें और बफ़र के डेटाटाइप की दोबारा व्याख्या करें।

यदि स्थिति::ओके() लौटाया जाता है, तो दोनों टेंसर अब समान अंतर्निहित भंडारण साझा करते हैं।

इस कॉल के लिए आवश्यक है कि other टेंसर और दिए गए प्रकार और आकार "संगत" हों (अर्थात वे समान संख्या में बाइट्स लेते हैं)।

विशेष रूप से:

आकार.num_elements() * डेटा प्रकार आकार (प्रकार)

बराबर होना चाहिए

अन्य.num_elements() * डेटा प्रकार आकार(अन्य.dtype())

इसके अलावा, इस फ़ंक्शन की आवश्यकता है:

  • डेटाटाइपसाइज़(अन्य.dtype()) != 0
  • डेटा प्रकार आकार(प्रकार) != 0

यदि कोई भी आवश्यकता पूरी नहीं होती है, तोErrors::InvalidArgument वापस आ जाता है।

से प्रतिलिपि बनाएँ

bool CopyFrom(
  const Tensor & other,
  const TensorShape & shape
) TF_MUST_USE_RESULT

अन्य टेंसर को इस टेंसर में कॉपी करें और इसे नया आकार दें।

यह टेंसर दूसरे के अंतर्निहित भंडारण को साझा करता है। यदि other.shape() में दिए गए shape के तत्वों की संख्या समान है तो true लौटाता है।

डीबगस्ट्रिंग

string DebugString(
  int num_values
) const 

डिबगिंग के लिए उपयुक्त टेंसर का मानव-पठनीय सारांश।

डीबगस्ट्रिंग

string DebugString() const 

डिवाइससेफडिबगस्ट्रिंग

string DeviceSafeDebugString() const 

विवरण भरें

void FillDescription(
  TensorDescription *description
) const 

TensorDescription प्रोटो को टेंसर के बारे में मेटाडेटा के साथ भरें जो मॉनिटरिंग और डिबगिंग के लिए उपयोगी है।

प्रोटो से

bool FromProto(
  const TensorProto & other
) TF_MUST_USE_RESULT

other पार्स करें और टेंसर का निर्माण करें।

यदि पार्सिंग सफल हो जाती है तो यह true लौटाता है। यदि पार्सिंग विफल हो जाती है, *this स्थिति अपरिवर्तित रहती है।

प्रोटो से

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

संरेखित है

bool IsAligned() const 

यदि यह टेंसर संरेखित है तो सत्य लौटाता है।

प्रारंभ किया गया है

bool IsInitialized() const 

यदि आवश्यक हो, तो क्या इस टेंसर को आरंभीकृत किया गया है?

शून्य-तत्व टेंसर को हमेशा आरंभीकृत माना जाता है, भले ही उन्हें कभी भी असाइन नहीं किया गया हो और उनके पास कोई मेमोरी आवंटित न हो।

एकसमानआकार है

bool IsSameSize(
  const Tensor & b
) const 

संख्या तत्व

int64 NumElements() const 

टेंसर आकार के लिए सुविधा सहायक।

शेयर्सबफ़रविथ

bool SharesBufferWith(
  const Tensor & b
) const 

टुकड़ा

Tensor Slice(
  int64 dim0_start,
  int64 dim0_limit
) const 

इस टेंसर को पहले आयाम के साथ काटें।

यानी, लौटाया गया टेंसर लौटाए गए [i, ...] == इस [dim0_start + i, ...] को संतुष्ट करता है। लौटाया गया टेंसर इस टेंसर के साथ अंतर्निहित टेंसर बफर साझा करता है।

नोट: लौटाया गया टेंसर आकार के आधार पर इस टेंसर के समान संरेखण आवश्यकता को पूरा नहीं कर सकता है। कॉल करने वाले को संरेखण आवश्यकता वाले कुछ तरीकों को कॉल करने से पहले लौटाए गए टेंसर के संरेखण की जांच करनी चाहिए (उदाहरण के लिए, flat() , tensor() )।

ध्यान दें: जब एन-आयामी टेंसर के साथ फीड किया जाता है, तो यह विधि एन आयामों के साथ भी एक टेंसर लौटाती है। यदि आप सब टेंसर का चयन करना चाहते हैं, तो सबस्लाइस देखें।

आवश्यकताएँ: dims() >= 1 आवश्यकताएँ: 0 <= dim0_start <= dim0_limit <= dim_size(0)

उपस्लाइस

Tensor SubSlice(
  int64 index
) const 

पहले आयाम के साथ इस टेंसर से एक उपस्लाइस का चयन करें।

जब एन-डायमेंशनल टेंसर के साथ फीड किया जाता है, तो यह विधि एन-1 आयामों के साथ एक टेंसर लौटाती है, जहां लौटाया गया टेंसर पहले आयाम के साथ इनपुट टेंसर का एक उप-स्लाइस होता है। लौटाए गए टेंसर के N-1 आयाम इनपुट टेंसर के अंतिम N-1 आयाम हैं।

नोट: लौटाया गया टेंसर आकार के आधार पर इस टेंसर के समान संरेखण आवश्यकता को पूरा नहीं कर सकता है। कॉल करने वाले को संरेखण आवश्यकता वाले कुछ तरीकों को कॉल करने से पहले लौटाए गए टेंसर के संरेखण की जांच करनी चाहिए (उदाहरण के लिए, flat() , tensor() )।

आवश्यकताएँ: dims() >= 1 आवश्यकताएँ: 0 <= dim0_start < dim_size(0)

सारांश मान

string SummarizeValue(
  int64 max_entries,
  bool print_v2
) const 

*this में पहले max_entries मानों को एक स्ट्रिंग में प्रस्तुत करें।

टेन्सर

 Tensor()

एक 1-आयामी, 0-तत्व फ्लोट टेंसर बनाता है।

लौटाया गया टेंसर एक अदिश (आकार {}) नहीं है, बल्कि इसके बजाय एक खाली एक-आयामी टेंसर (आकार {0}, NumElements() == 0) है। चूँकि इसमें कोई तत्व नहीं है, इसलिए इसे कोई मान निर्दिष्ट करने की आवश्यकता नहीं है और इसे डिफ़ॉल्ट रूप से प्रारंभ किया जाता है ( IsInitialized() सत्य है)। यदि यह अवांछनीय है, तो एक-तत्व स्केलर बनाने पर विचार करें जिसके लिए आरंभीकरण की आवश्यकता होती है:

Tensor(DT_FLOAT, TensorShape({}))

      

Tensor

 Tensor(
  DataType type,
  const TensorShape & shape
)

दिए गए type और shape का एक टेंसर बनाता है।

यदि LogMemory::IsEnabled() आवंटन किसी अज्ञात कर्नेल और चरण से आने के रूप में लॉग किया गया है। किसी Op के भीतर से सीधे Tensor कंस्ट्रक्टर को कॉल करना अस्वीकार्य है: एक नया टेंसर आवंटित करने के लिए OpKernelConstruction/OpKernelContext allocate_* विधियों का उपयोग करें, जो कर्नेल और चरण को रिकॉर्ड करता है।

अंतर्निहित बफ़र को CPUAllocator उपयोग करके आवंटित किया जाता है।

टेन्सर

 Tensor(
  Allocator *a,
  DataType type,
  const TensorShape & shape
)

अंतर्निहित बफ़र को आवंटित करने के लिए एलोकेटर का उपयोग करके इनपुट type और shape a साथ एक टेंसर बनाता है।

यदि LogMemory::IsEnabled() आवंटन किसी अज्ञात कर्नेल और चरण से आने के रूप में लॉग किया गया है। किसी Op के भीतर से सीधे Tensor कंस्ट्रक्टर को कॉल करना अस्वीकार्य है: एक नया टेंसर आवंटित करने के लिए OpKernelConstruction/OpKernelContext allocate_* विधियों का उपयोग करें, जो कर्नेल और चरण को रिकॉर्ड करता है।

इस टेंसर के जीवनकाल को पूरा करना a है।

टेन्सर

 Tensor(
  Allocator *a,
  DataType type,
  const TensorShape & shape,
  const AllocationAttributes & allocation_attr
)

अंतर्निहित बफ़र को आवंटित करने के लिए एलोकेटर a और निर्दिष्ट "allocation_attr" का उपयोग करके इनपुट type और shape के साथ एक टेंसर बनाता है।

यदि कर्नेल और चरण ज्ञात हैं, तो allocation_attr.allocation_will_be_logged को सत्य पर सेट किया जाना चाहिए और टेंसर के निर्माण के बाद LogMemory::RecordTensorAllocation को कॉल किया जाना चाहिए। किसी Op के भीतर से सीधे Tensor कंस्ट्रक्टर को कॉल करना अस्वीकार्य है: एक नया टेंसर आवंटित करने के लिए OpKernelConstruction/OpKernelContext allocate_* विधियों का उपयोग करें, जो कर्नेल और चरण को रिकॉर्ड करता है।

इस टेंसर के जीवनकाल को पूरा करना a है।

टेन्सर

 Tensor(
  DataType type,
  const TensorShape & shape,
  TensorBuffer *buf
)

इनपुट डेटाटाइप, आकार और buf के साथ एक टेंसर बनाता है।

buf पर एक रेफरी प्राप्त करता है जो इस Tensor से संबंधित है।

टेन्सर

 Tensor(
  DataType type
)

दिए गए डेटा प्रकार का एक खाली टेंसर बनाता है।

Tensor() की तरह, IsInitialized() के साथ 1-आयामी, 0-तत्व Tensor लौटाता है, जो True लौटाता है। विवरण के लिए Tensor() दस्तावेज़ देखें।

टेन्सर

 Tensor(
  float scalar_value
)

टेन्सर

 Tensor(
  double scalar_value
)

टेन्सर

 Tensor(
  int32 scalar_value
)

टेन्सर

 Tensor(
  uint32 scalar_value
)

टेन्सर

 Tensor(
  uint16 scalar_value
)

टेन्सर

 Tensor(
  uint8 scalar_value
)

टेन्सर

 Tensor(
  int16 scalar_value
)

टेन्सर

 Tensor(
  int8 scalar_value
)

टेन्सर

 Tensor(
  tstring scalar_value
)

टेन्सर

 Tensor(
  complex64 scalar_value
)

टेन्सर

 Tensor(
  complex128 scalar_value
)

टेन्सर

 Tensor(
  int64 scalar_value
)

टेन्सर

 Tensor(
  uint64 scalar_value
)

टेन्सर

 Tensor(
  bool scalar_value
)

टेन्सर

 Tensor(
  qint8 scalar_value
)

टेन्सर

 Tensor(
  quint8 scalar_value
)

टेन्सर

 Tensor(
  qint16 scalar_value
)

टेन्सर

 Tensor(
  quint16 scalar_value
)

टेन्सर

 Tensor(
  qint32 scalar_value
)

टेन्सर

 Tensor(
  bfloat16 scalar_value
)

टेन्सर

 Tensor(
  Eigen::half scalar_value
)

टेन्सर

 Tensor(
  ResourceHandle scalar_value
)

टेन्सर

 Tensor(
  const char *scalar_value
)

टेन्सर

 Tensor(
  const Tensor & other
)

कंस्ट्रक्टर कॉपी करें.

टेन्सर

 Tensor(
  Tensor && other
)

कंस्ट्रक्टर को स्थानांतरित करें।

इस कॉल के बाद, सुरक्षित रूप से नष्ट होने योग्य है और इसे सौंपा जा सकता है, लेकिन इस पर अन्य कॉल (जैसे आकार में हेरफेर) मान्य नहीं हैं।

कुलबाइट्स

size_t TotalBytes() const 

इस टेंसर का अनुमानित मेमोरी उपयोग लौटाता है।

आंतरिक से असुरक्षित प्रतिलिपि

void UnsafeCopyFromInternal(
  const Tensor & other,
  DataType dtype,
  const TensorShape & shape
)

BitcastFrom की तरह, लेकिन यदि कोई पूर्व शर्त पूरी नहीं होती है तो CHECK विफल हो जाता है।

बहिष्कृत. इसके बजाय BitcastFrom का उपयोग करें और लौटाए गए स्टेटस की जांच करें।

बिट_कास्ट_शेप्ड

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

टेंसर डेटा को new_sizes में निर्दिष्ट नए आकार के साथ Eigen::Tensor पर लौटाएं और एक नए dtype T पर डालें।

स्थानांतरण और प्रतिलिपि संचालन के लिए बिटकास्ट का उपयोग उपयोगी है। अनुमत बिटकास्ट shaped() से एकमात्र अंतर है।

बिट_कास्ट_शेप्ड

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

टेंसर डेटा को new_sizes में निर्दिष्ट नए आकार के साथ Eigen::Tensor पर लौटाएं और एक नए dtype T पर डालें।

स्थानांतरण और प्रतिलिपि संचालन के लिए बिटकास्ट का उपयोग उपयोगी है। अनुमत बिटकास्ट shaped() से एकमात्र अंतर है।

बिट_कास्टेड_टेंसर

TTypes< T, NDIMS >::Tensor bit_casted_tensor()

टेंसर डेटा को समान आकार वाले Eigen::Tensor पर लौटाएं लेकिन निर्दिष्ट dtype T पर बिटवाइज़ कास्ट करें।

स्थानांतरण और प्रतिलिपि संचालन के लिए बिटकास्ट का उपयोग उपयोगी है। नोट: यह tensor() के समान है, सिवाय इसके कि बिटकास्ट की अनुमति है।

बिट_कास्टेड_टेंसर

TTypes< T, NDIMS >::ConstTensor bit_casted_tensor() const 

टेंसर डेटा को समान आकार वाले Eigen::Tensor पर लौटाएं लेकिन निर्दिष्ट dtype T पर बिटवाइज़ कास्ट करें।

स्थानांतरण और प्रतिलिपि संचालन के लिए बिटकास्ट का उपयोग उपयोगी है। नोट: यह tensor() के समान है, सिवाय इसके कि बिटकास्ट की अनुमति है।

मंद_आकार

int64 dim_size(
  int d
) const 

टेंसर आकार के लिए सुविधा सहायक।

धुंधली हो जाती है

int dims() const 

टेंसर आकार के लिए सुविधा सहायक।

सभी आकार एक्सेसर्स के लिए, tensor_shape.h में TensorShape के प्रासंगिक तरीकों के लिए टिप्पणियाँ देखें।

dtype

DataType dtype() const 

डेटा प्रकार लौटाता है.

समतल

TTypes< T >::Flat flat()

टेंसर डेटा को डेटा प्रकार और एक निर्दिष्ट आकार के Eigen::Tensor के रूप में लौटाएँ।

ये विधियां आपको अपनी पसंद के आयामों और आकारों के साथ डेटा तक पहुंचने की अनुमति देती हैं। आपको उन्हें कॉल करने के लिए टेन्सर के आयामों की संख्या जानने की आवश्यकता नहीं है। हालाँकि, वे CHECK कि प्रकार मेल खाता है और अनुरोधित आयाम टेंसर के समान तत्वों के साथ एक Eigen::Tensor बनाता है।

उदाहरण:

  
    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({4, 15});
    // CHECK fails, bad num elements:
    auto outer = my_ten.shaped({4, 8});
    // 3D Eigen::Tensor 6 x 5 x 2:
    auto weird = my_ten.shaped({6, 5, 2});
    // CHECK fails, type mismatch:
    auto bad   = my_ten.flat();

      

flat

TTypes< T >::ConstFlat flat() const 

सपाट_आंतरिक_मंद

TTypes< T, NDIMS >::Tensor flat_inner_dims()

डेटा को NDIMS आयामों के साथ Eigen::Tensor के रूप में लौटाता है, अंतिम NDIMS-1 को छोड़कर सभी Tensor आयामों को परिणाम के पहले आयाम में संक्षिप्त करता है।

यदि NDIMS > dims() तो आउटपुट रैंक NDIMS बनाने के लिए आकार 1 के प्रमुख आयाम जोड़े जाएंगे।

सपाट_आंतरिक_मंद

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

सपाट_आंतरिक_बाहरी_मंद

TTypes< T, NDIMS >::Tensor flat_inner_outer_dims(
  int64 begin
)

डेटा को NDIMS आयामों के साथ Eigen::Tensor के रूप में लौटाता है, पहले 'प्रारंभ' Tensor आयामों को परिणाम के पहले आयाम में और अंतिम dims() - 'begin' - NDIMS के Tensor आयामों को अंतिम आयाम में संक्षिप्त करता है। परिणाम।

यदि 'शुरू' < 0 है तो |'शुरू'| आकार 1 के प्रमुख आयाम जोड़े जाएंगे। यदि 'begin' + NDIMS > dims() तो 'begin' + NDIMS - dims() आकार 1 के अनुगामी आयाम जोड़े जाएंगे।

सपाट_आंतरिक_बाहरी_मंद

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

सपाट_बाहरी_मंद

TTypes< T, NDIMS >::Tensor flat_outer_dims()

डेटा को NDIMS आयामों के साथ Eigen::Tensor के रूप में लौटाता है, परिणाम के अंतिम आयाम में पहले NDIMS-1 को छोड़कर सभी Tensor आयामों को संक्षिप्त करता है।

यदि NDIMS > dims() तो आउटपुट रैंक NDIMS बनाने के लिए आकार 1 के अनुगामी आयाम जोड़े जाएंगे।

सपाट_बाहरी_मंद

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

आव्यूह

TTypes< T >::Matrix matrix()

आव्यूह

TTypes< T >::ConstMatrix matrix() const 

ऑपरेटर=

Tensor & operator=(
  const Tensor & other
)

ऑपरेटर नियुक्त करें. यह टेंसर दूसरे के अंतर्निहित भंडारण को साझा करता है।

ऑपरेटर=

Tensor & operator=(
  Tensor && other
)

ऑपरेटर ले जाएँ. विवरण के लिए मूव कंस्ट्रक्टर देखें।

पुनःव्याख्या_अंतिम_आयाम

TTypes< T, NDIMS >::Tensor reinterpret_last_dimension()

टेंसर डेटा को Eigen::Tensor पर लौटाएं, जिसमें अंतिम आयाम वाले तत्व बड़े प्रकार के एकल तत्वों में परिवर्तित हो जाएं।

उदाहरण के लिए, यह उन कर्नेल के लिए उपयोगी है जो NCHW_VECT_C int8 टेंसर को NCHW int32 टेंसर के रूप में मान सकते हैं। sizeof(T) मूल अंतिम आयाम में मूल तत्व प्रकार * संख्या तत्वों के आकार के बराबर होना चाहिए। एनडीआईएमएस आयामों की मूल संख्या से 1 कम होना चाहिए।

पुनःव्याख्या_अंतिम_आयाम

TTypes< T, NDIMS >::ConstTensor reinterpret_last_dimension() const 

टेंसर डेटा को Eigen::Tensor पर लौटाएं, जिसमें अंतिम आयाम वाले तत्व बड़े प्रकार के एकल तत्वों में परिवर्तित हो जाएं।

उदाहरण के लिए, यह उन कर्नेल के लिए उपयोगी है जो NCHW_VECT_C int8 टेंसर को NCHW int32 टेंसर के रूप में मान सकते हैं। sizeof(T) मूल अंतिम आयाम में मूल तत्व प्रकार * संख्या तत्वों के आकार के बराबर होना चाहिए। एनडीआईएमएस आयामों की मूल संख्या से 1 कम होना चाहिए।

अदिश

TTypes< T >::Scalar scalar()

Tensor डेटा को निश्चित आकार 1 के TensorMap के रूप में लौटाएँ: TensorMap > TensorMap > .

scalar() का उपयोग करने से कंपाइलर को अनुकूलन करने की अनुमति मिलती है क्योंकि कंपाइल समय पर टेंसर का आकार ज्ञात होता है।

अदिश

TTypes< T >::ConstScalar scalar() const 

आकार

const TensorShape & shape() const 

टेंसर का आकार लौटाता है.

आकार

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

आकार

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

टेन्सर

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

टेन्सर

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

टेंसर_डेटा

StringPiece tensor_data() const 

वर्तमान टेंसर के बफ़र को मैप करते हुए एक StringPiece लौटाता है।

लौटाया गया StringPiece उन डिवाइसों पर मेमोरी स्थान को इंगित कर सकता है जिन्हें सीपीयू सीधे संबोधित नहीं कर सकता है।

नोट: अंतर्निहित टेंसर बफ़र की पुनर्गणना की जाती है, इसलिए StringPiece द्वारा मैप की गई सामग्री का जीवनकाल बफ़र के जीवनकाल से मेल खाता है; कॉल करने वालों को यह सुनिश्चित करने की व्यवस्था करनी चाहिए कि StringPiece के अभी भी उपयोग होने पर बफ़र नष्ट न हो जाए।

आवश्यकताएँ: DataTypeCanUseMemcpy(dtype())

असंरेखित_सपाट

TTypes< T >::UnalignedFlat unaligned_flat()

असंरेखित_सपाट

TTypes< T >::UnalignedConstFlat unaligned_flat() const 

असंरेखित_आकार

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

असंरेखित_आकार

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

वी.ई.सी

TTypes< T >::Vec vec()

इस Tensor के प्रकार और आकार के साथ Tensor डेटा को Eigen::Tensor के रूप में लौटाएँ।

जब आप डेटा प्रकार और Tensor के आयामों की संख्या जानते हैं और आप चाहते हैं कि Eigen::Tensor स्वचालित रूप से Tensor आकार के अनुसार आकार में आ जाए, तो इन विधियों का उपयोग करें। यदि प्रकार या आकार बेमेल है तो कार्यान्वयन जांच विफल हो जाती है।

उदाहरण:

l10n-प्लेसहोल्डर89

एल10एन-प्लेसहोल्डर90

उपरोक्त सभी विधियों के कॉन्स्ट संस्करण।

~टेन्सर

एल10एन-प्लेसहोल्डर91