टेन्सरफ्लो:: टेन्सर
#include <tensor.h>यह मानों की n-आयामी सरणी को दर्शाता है।
सारांश
कंस्ट्रक्टर और डिस्ट्रक्टर | |
|---|---|
Tensor () यह एक आयामी, शून्य-तत्व वाला फ्लोट टेंसर बनाता है। | |
Tensor (DataType type, const TensorShape & shape) | |
Tensor (Allocator *a, DataType type, const TensorShape & shape) इनपुट type और shape के साथ एक टेंसर बनाता है, अंतर्निहित बफर को आवंटित करने के लिए एलोकेटर a का उपयोग करता है। | |
Tensor (Allocator *a, DataType type, const TensorShape & shape, const AllocationAttributes & allocation_attr) इनपुट type और shape के साथ एक टेंसर बनाता है, अंतर्निहित बफर को आवंटित करने के लिए एलोकेटर a और निर्दिष्ट "allocation_attr" का उपयोग करता है। | |
Tensor (DataType type, const TensorShape & shape, TensorBuffer *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*this टेंसर की सामग्री से proto को भरता है। |
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 | voidTensorDescription proto में टेंसर के बारे में उपयोगी मेटाडेटा भरें जो मॉनिटरिंग और डिबगिंग के लिए उपयोगी हो। |
FromProto (const TensorProto & other) TF_MUST_USE_RESULT | boolother पार्स करें और टेंसर का निर्माण करें। |
FromProto (Allocator *a, const TensorProto & other) TF_MUST_USE_RESULT | bool |
IsAligned () const | bool यदि यह टेंसर संरेखित है तो यह true लौटाता है। |
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 टेंसर डेटा को समान आकार वाले लेकिन निर्दिष्ट डेटाटाइप T में बिटवाइज कास्ट किए गए Eigen::Tensor में लौटाएँ। |
bit_casted_tensor () const | TTypes< T, NDIMS >::ConstTensor टेंसर डेटा को समान आकार वाले लेकिन निर्दिष्ट डेटाटाइप T में बिटवाइज कास्ट किए गए Eigen::Tensor में लौटाएँ। |
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 |
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) | Tensor & असाइन ऑपरेटर। यह टेंसर दूसरे के अंतर्निहित स्टोरेज को साझा करता है। |
operator= ( Tensor && other) | Tensor & मूव ऑपरेटर। विवरण के लिए मूव कंस्ट्रक्टर देखें। |
reinterpret_last_dimension () | TTypes< T, NDIMS >:: Tensor टेंसर डेटा को एक Eigen::Tensor में लौटाएं, जिसमें अंतिम आयाम के तत्वों को एक बड़े प्रकार के एकल तत्वों में परिवर्तित किया गया हो। |
reinterpret_last_dimension () const | TTypes< T, NDIMS >::ConstTensor टेंसर डेटा को एक Eigen::Tensor में लौटाएं, जिसमें अंतिम आयाम के तत्वों को एक बड़े प्रकार के एकल तत्वों में परिवर्तित किया गया हो। |
scalar () | TTypes< T >::Scalar |
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 के प्रकार और आकार के साथ टेंसर डेटा को एक Eigen::Tensor के रूप में लौटाएँ। |
vec () const | TTypes< T >::ConstVec ऊपर दिए गए सभी तरीकों के कॉन्स्टेंट संस्करण। |
सार्वजनिक समारोह
आवंटित बाइट्स
size_t AllocatedBytes() const
AsProtoField
void AsProtoField( TensorProto *proto ) const
*this टेंसर की सामग्री से proto को भरता है।
AsProtoField() proto.dtype() के लिए दोहराए गए फ़ील्ड को भरता है, जबकि AsProtoTensorContent() proto.tensor_content() में मौजूद सामग्री को संक्षिप्त रूप में एन्कोड करता है।
AsProtoTensorContent
void AsProtoTensorContent( TensorProto *proto ) const
बिटकास्टफ्रॉम
Status BitcastFrom( const Tensor & other, DataType dtype, const TensorShape & shape )
दूसरे टेंसर को इस टेंसर में कॉपी करें, इसे रीशेप करें और बफर के डेटाटाइप को पुनर्व्याख्यायित करें।
यदि Status::OK() मान लौटाया जाता है, तो दोनों टेंसर अब एक ही अंतर्निहित स्टोरेज को साझा करते हैं।
इस कॉल के लिए यह आवश्यक है कि other टेंसर और दिया गया प्रकार और आकार "संगत" हों (अर्थात, वे समान संख्या में बाइट्स घेरते हों)।
विशेष रूप से:
आकार.num_elements() * डेटाटाइपसाइज़(प्रकार)
बराबर होना चाहिए
अन्य.num_elements() * डेटाटाइपसाइज़(अन्य.डीटाइप())
इसके अतिरिक्त, इस फ़ंक्शन के लिए निम्नलिखित की आवश्यकता है:
- DataTypeSize(other.dtype()) != 0
- DataTypeSize(type) != 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 proto में टेंसर के बारे में उपयोगी मेटाडेटा भरें जो मॉनिटरिंग और डिबगिंग के लिए उपयोगी हो।
फ्रॉमप्रोटो
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
यदि यह टेंसर संरेखित है तो यह true लौटाता है।
आरंभ किया गया
bool IsInitialized() const
यदि आवश्यक हो, तो क्या इस टेंसर को इनिशियलाइज़ किया गया है?
शून्य-तत्व वाले टेंसरों को हमेशा आरंभिक माना जाता है, भले ही उन्हें कभी कोई मान नहीं दिया गया हो और उनके लिए कोई मेमोरी आवंटित न की गई हो।
IsSameSize
bool IsSameSize( const Tensor & b ) const
NumElements
int64 NumElements() const
टेंसर आकार के लिए सुविधाजनक एक्सेसरी।
शेयर्सबफरविद
bool SharesBufferWith( const Tensor & b ) const
टुकड़ा
Tensor Slice( int64 dim0_start, int64 dim0_limit ) const
इस टेंसर को पहले आयाम के अनुदिश विभाजित करें।
यानी, लौटाया गया टेंसर returned[i, ...] == this[dim0_start + i, ...] को संतुष्ट करता है। लौटाया गया टेंसर इस टेंसर के साथ अंतर्निहित टेंसर बफर साझा करता है।
नोट: लौटाया गया टेंसर, आकार के आधार पर, इस टेंसर के समान संरेखण आवश्यकता को पूरा नहीं कर सकता है। संरेखण आवश्यकता वाले कुछ तरीकों (जैसे, flat() , tensor() ) को कॉल करने से पहले कॉलर को लौटाए गए टेंसर के संरेखण की जांच करनी चाहिए।
नोट: जब इस विधि को N-आयामी टेंसर दिया जाता है, तो यह N आयामों वाला टेंसर लौटाती है। यदि आप एक उप-टेंसर का चयन करना चाहते हैं, तो सबस्लाइस देखें।
आवश्यकता: dims() >= 1 आवश्यकता: 0 <= dim0_start <= dim0_limit <= dim_size(0)
सबस्लाइस
Tensor SubSlice( int64 index ) const
इस टेंसर से पहली विमा के अनुदिश एक उपस्लाइस का चयन करें।
जब इस विधि को N-आयामी टेंसर दिया जाता है, तो यह N-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()
यह एक आयामी, शून्य-तत्व वाला फ्लोट टेंसर बनाता है।
लौटाया गया टेंसर एक स्केलर (आकार {}) नहीं है, बल्कि एक खाली एक-आयामी टेंसर (आकार {0}, NumElements() == 0) है। चूंकि इसमें कोई तत्व नहीं है, इसलिए इसे कोई मान असाइन करने की आवश्यकता नहीं है और यह डिफ़ॉल्ट रूप से इनिशियलाइज़्ड होता है ( IsInitialized() सत्य है)। यदि यह अवांछनीय है, तो एक-तत्व स्केलर बनाने पर विचार करें जिसे इनिशियलाइज़ेशन की आवश्यकता होती है:
Tensor(DT_FLOAT, TensorShape({}))
Tensor
Tensor( DataType type, const TensorShape & shape )
दिए गए type और shape का टेंसर बनाता है।
यदि LogMemory::IsEnabled() का उपयोग किया जाता है, तो आवंटन को अज्ञात कर्नेल और चरण से आने वाले के रूप में लॉग किया जाता है। किसी ऑप के भीतर से सीधे टेंसर कंस्ट्रक्टर को कॉल करना अप्रचलित है: एक नया टेंसर आवंटित करने के लिए OpKernelConstruction/OpKernelContext allocate_* विधियों का उपयोग करें, जो कर्नेल और चरण को रिकॉर्ड करते हैं।
अंतर्निहित बफर को CPUAllocator का उपयोग करके आवंटित किया जाता है।
टेन्सर
Tensor( Allocator *a, DataType type, const TensorShape & shape )
इनपुट type और shape के साथ एक टेंसर बनाता है, अंतर्निहित बफर को आवंटित करने के लिए एलोकेटर a का उपयोग करता है।
यदि LogMemory::IsEnabled() का उपयोग किया जाता है, तो आवंटन को अज्ञात कर्नेल और चरण से आने वाले के रूप में लॉग किया जाता है। किसी ऑप के भीतर से सीधे टेंसर कंस्ट्रक्टर को कॉल करना अप्रचलित है: एक नया टेंसर आवंटित करने के लिए OpKernelConstruction/OpKernelContext allocate_* विधियों का उपयोग करें, जो कर्नेल और चरण को रिकॉर्ड करते हैं।
इस टेंसर के जीवनकाल से अधिक समय तक जीवित रहना a है।
टेन्सर
Tensor( Allocator *a, DataType type, const TensorShape & shape, const AllocationAttributes & allocation_attr )
इनपुट type और shape के साथ एक टेंसर बनाता है, अंतर्निहित बफर को आवंटित करने के लिए एलोकेटर a और निर्दिष्ट "allocation_attr" का उपयोग करता है।
यदि कर्नेल और स्टेप ज्ञात हों, तो allocation_attr.allocation_will_be_logged को true पर सेट किया जाना चाहिए और टेंसर के निर्माण के बाद LogMemory::RecordTensorAllocation को कॉल किया जाना चाहिए। किसी ऑप के भीतर से सीधे टेंसर कंस्ट्रक्टर को कॉल करना अप्रचलित है: कर्नेल और स्टेप को रिकॉर्ड करने वाले नए टेंसर को आवंटित करने के लिए OpKernelConstruction/OpKernelContext allocate_* विधियों का उपयोग करें।
इस टेंसर के जीवनकाल से अधिक समय तक जीवित रहना a है।
टेन्सर
Tensor( DataType type, const TensorShape & shape, TensorBuffer *buf )
इनपुट डेटाटाइप, आकार और बफर के साथ एक टेंसर बनाता है।
यह टेंसर से संबंधित buf पर एक ref प्राप्त करता है।
टेन्सर
Tensor( DataType type )
दिए गए डेटा प्रकार का एक खाली टेंसर बनाता है।
Tensor() फ़ंक्शन की तरह, यह भी एक आयामी, 0-तत्व वाला Tensor लौटाता है, जिसमें IsInitialized() का मान 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( Tensor && other )
मूव कंस्ट्रक्टर।
इस कॉल के बाद,
कुल बाइट्स
size_t TotalBytes() const
यह टेंसर द्वारा उपयोग की जाने वाली अनुमानित मेमोरी की मात्रा लौटाता है।
UnsafeCopyFromInternal
void UnsafeCopyFromInternal( const Tensor & other, DataType dtype, const TensorShape & shape )
BitcastFrom की तरह ही, लेकिन यदि कोई पूर्व शर्त पूरी नहीं होती है तो CHECK विफल हो जाता है।
अप्रचलित। इसके बजाय BitcastFrom का उपयोग करें और लौटाए गए Status की जाँच करें।
बिट_कास्टेड_शेप्ड
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()
टेंसर डेटा को समान आकार वाले लेकिन निर्दिष्ट डेटाटाइप T में बिटवाइज कास्ट किए गए Eigen::Tensor में लौटाएँ।
बिटकास्ट का उपयोग मूव और कॉपी ऑपरेशन के लिए उपयोगी है। नोट: यह tensor() के समान है, सिवाय इसके कि इसमें बिटकास्ट की अनुमति है।
बिट_कास्टेड_टेंसर
TTypes< T, NDIMS >::ConstTensor bit_casted_tensor() const
टेंसर डेटा को समान आकार वाले लेकिन निर्दिष्ट डेटाटाइप T में बिटवाइज कास्ट किए गए Eigen::Tensor में लौटाएँ।
बिटकास्ट का उपयोग मूव और कॉपी ऑपरेशन के लिए उपयोगी है। नोट: यह tensor() के समान है, सिवाय इसके कि इसमें बिटकास्ट की अनुमति है।
आयामी आकार
int64 dim_size( int d ) const
टेंसर आकार के लिए सुविधाजनक एक्सेसरी।
धुंधली हो जाती है
int dims() const
टेंसर आकार के लिए सुविधाजनक एक्सेसरी।
सभी शेप एक्सेसर्स के लिए, tensor_shape.h में TensorShape की संबंधित विधियों के लिए टिप्पणियाँ देखें।
डीटाइप
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<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 ();
flat
TTypes< T >::ConstFlat flat() const
फ्लैट_इनर_डिम्स
TTypes< T, NDIMS >::Tensor flat_inner_dims()
फ्लैट_इनर_डिम्स
TTypes< T, NDIMS >::ConstTensor flat_inner_dims() const
फ्लैट_इनर_आउटर_डाइमेंशन
TTypes< T, NDIMS >::Tensor flat_inner_outer_dims( int64 begin )
यह डेटा को NDIMS आयामों वाले Eigen::Tensor के रूप में लौटाता है, जिसमें पहले 'begin' टेंसर के आयामों को परिणाम के पहले आयाम में और अंतिम dims() - 'begin' - NDIMS के टेंसर आयामों को परिणाम के अंतिम आयाम में संकुचित किया जाता है।
यदि 'begin' < 0 है, तो |'begin'| के बराबर आकार के पहले आयाम (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()
फ्लैट_बाहरी_आयाम
TTypes< T, NDIMS >::ConstTensor flat_outer_dims() const
मैट्रिक्स
TTypes< T >::Matrix matrix()
मैट्रिक्स
TTypes< T >::ConstMatrix matrix() const
ऑपरेटर=
Tensor & operator=( const Tensor & other )
असाइन ऑपरेटर। यह टेंसर दूसरे के अंतर्निहित स्टोरेज को साझा करता है।
अंतिम आयाम की पुनर्व्याख्या करें
TTypes< T, NDIMS >::Tensor reinterpret_last_dimension()
टेंसर डेटा को एक Eigen::Tensor में लौटाएं, जिसमें अंतिम आयाम के तत्वों को एक बड़े प्रकार के एकल तत्वों में परिवर्तित किया गया हो।
उदाहरण के लिए, यह उन कर्नेल के लिए उपयोगी है जो NCHW_VECT_C int8 टेंसर को NCHW int32 टेंसर के रूप में मान सकते हैं। sizeof(T) मूल तत्व प्रकार के आकार * मूल अंतिम आयाम में तत्वों की संख्या के बराबर होना चाहिए। NDIMS मूल आयामों की संख्या से 1 कम होना चाहिए।
अंतिम आयाम की पुनर्व्याख्या करें
TTypes< T, NDIMS >::ConstTensor reinterpret_last_dimension() const
टेंसर डेटा को एक Eigen::Tensor में लौटाएं, जिसमें अंतिम आयाम के तत्वों को एक बड़े प्रकार के एकल तत्वों में परिवर्तित किया गया हो।
उदाहरण के लिए, यह उन कर्नेल के लिए उपयोगी है जो NCHW_VECT_C int8 टेंसर को NCHW int32 टेंसर के रूप में मान सकते हैं। sizeof(T) मूल तत्व प्रकार के आकार * मूल अंतिम आयाम में तत्वों की संख्या के बराबर होना चाहिए। NDIMS मूल आयामों की संख्या से 1 कम होना चाहिए।
अदिश
TTypes< T >::Scalar 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 उन डिवाइसों पर मेमोरी लोकेशन को इंगित कर सकता है जिन्हें CPU सीधे संबोधित नहीं कर सकता है।
नोट: अंतर्निहित टेंसर बफर रेफ़काउंटेड है, इसलिए 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()
इस टेंसर के प्रकार और आकार के साथ टेंसर डेटा को एक आइगेन::टेंसर के रूप में लौटाएँ।
इन विधियों का उपयोग तब करें जब आपको टेंसर का डेटा प्रकार और आयामों की संख्या ज्ञात हो और आप चाहते हों कि Eigen::Tensor का आकार स्वचालित रूप से टेंसर के आकार के अनुसार निर्धारित हो जाए। यदि प्रकार या आकार में कोई विसंगति हो तो कार्यान्वयन जाँच विफल हो जाती है।
उदाहरण:
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.
vec
TTypes< T >::ConstVec vec() const
ऊपर दिए गए सभी तरीकों के कॉन्स्टेंट संस्करण।
~टेन्सर
~Tensor()