텐서플로우::텐서

#include <tensor.h>

n차원 값 배열을 나타냅니다.

요약

생성자와 소멸자

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)
입력 데이터 유형, 모양 및 버퍼를 사용하여 텐서를 생성합니다.
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)
Status
다른 텐서를 이 텐서로 복사하고, 형태를 변경한 다음 버퍼의 데이터 유형을 다시 해석합니다.
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
이 텐서가 정렬된 경우에만 true를 반환합니다.
IsInitialized () const
bool
필요한 경우, 이 텐서는 초기화되었습니까?
IsSameSize (const Tensor & b) const
bool
NumElements () const
int64
텐서 형상에 대한 편리한 접근자입니다.
RefCountIsOne () const
bool
SharesBufferWith (const Tensor & b) const
bool
Slice (int64 dim0_start, int64 dim0_limit) const
이 텐서를 1차원을 따라 자릅니다.
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 에 지정된 새 모양과 새 데이터 유형 T 로 캐스팅된 Eigen::Tensor 로 반환합니다.
bit_casted_shaped (gtl::ArraySlice< int64 > new_sizes) const
TTypes< T, NDIMS >::ConstTensor
텐서 데이터를 new_sizes 에 지정된 새 모양과 새 데이터 유형 T 로 캐스팅된 Eigen::Tensor 로 반환합니다.
bit_casted_tensor ()
TTypes< T, NDIMS >:: Tensor
텐서 데이터를 지정된 데이터 유형 T 로 비트 단위로 형변환하여 동일한 크기의 Eigen::Tensor 로 반환합니다.
bit_casted_tensor () const
TTypes< T, NDIMS >::ConstTensor
텐서 데이터를 지정된 데이터 유형 T 로 비트 단위로 형변환하여 동일한 크기의 Eigen::Tensor 로 반환합니다.
data () const
void *
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로 반환합니다. 이때 처음 'begin' 차원의 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
텐서 데이터를 크기가 1인 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 의 유형과 크기를 가진 Eigen::Tensor 형식으로 텐서 데이터를 반환합니다.
vec () const
TTypes< T >::ConstVec
위의 모든 메서드의 const 버전입니다.

공공 기능

할당된 바이트

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 

비트캐스트프롬

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

다른 텐서를 이 텐서로 복사하고, 형태를 변경한 다음 버퍼의 데이터 유형을 다시 해석합니다.

Status::OK()가 반환되면 두 텐서는 이제 동일한 기본 저장소를 공유합니다.

이 호출을 위해서는 other 텐서와 지정된 유형 및 모양이 "호환"되어야 합니다(즉, 동일한 바이트 수를 차지해야 합니다).

구체적으로:

shape.num_elements() * DataTypeSize(type)

같아야 합니다

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

또한, 이 기능을 사용하려면 다음이 필요합니다.

  • 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 

DeviceSafeDebugString

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 

이 텐서가 정렬된 경우에만 true를 반환합니다.

초기화됨

bool IsInitialized() const 

필요한 경우, 이 텐서는 초기화되었습니까?

요소가 0개인 텐서는 값이 할당되지 않았거나 메모리가 할당되지 않았더라도 항상 초기화된 것으로 간주됩니다.

크기가 같습니다

bool IsSameSize(
  const Tensor & b
) const 

요소 수

int64 NumElements() const 

텐서 형상에 대한 편리한 접근자입니다.

RefCountIsOne

bool RefCountIsOne() const 

SharesBufferWith

bool SharesBufferWith(
  const Tensor & b
) const 

일부분

Tensor Slice(
  int64 dim0_start,
  int64 dim0_limit
) const 

이 텐서를 1차원을 따라 자릅니다.

즉, 반환된 텐서는 returned[i, ...] == this[dim0_start + i, ...] 조건을 만족합니다. 반환된 텐서는 이 텐서와 기본 텐서 버퍼를 공유합니다.

참고: 반환된 텐서는 모양에 따라 이 텐서와 동일한 정렬 요구 사항을 충족하지 않을 수 있습니다. 호출자는 정렬 요구 사항이 있는 특정 메서드(예: flat() , tensor() )를 호출하기 전에 반환된 텐서의 정렬 상태를 확인해야 합니다.

참고: N차원 텐서를 입력으로 받으면 이 메서드는 N차원 텐서를 반환합니다. 부분 텐서를 선택하려면 SubSlice 메서드를 참조하십시오.

필수 조건: 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 <= index < dim_size(0)

요약값

string SummarizeValue(
  int64 max_entries,
  bool print_v2
) const 

*this 의 첫 번째 max_entries 값을 문자열로 렌더링합니다.

텐서

 Tensor()

1차원, 요소가 0개인 부동소수점 텐서를 생성합니다.

반환된 텐서는 스칼라(shape {})가 아니라 요소가 없는 1차원 텐서 (shape {0}, NumElements() == 0)입니다. 요소가 없으므로 값을 할당할 필요가 없으며 기본적으로 초기화됩니다( IsInitialized() 가 true). 이러한 동작이 바람직하지 않다면 초기화가 필요한 1차원 스칼라를 생성하는 것을 고려해 보세요.

Tensor(DT_FLOAT, TensorShape({}))

      

Tensor

 Tensor(
  DataType type,
  const TensorShape & shape
)

지정된 type 과 shape 의 텐서를 생성합니다.

LogMemory::IsEnabled()가 호출되면 할당된 메모리가 알 수 없는 커널과 스텝에서 발생한 것으로 기록됩니다. Op 내에서 Tensor 생성자를 직접 호출하는 것은 더 이상 권장되지 않습니다. 새 Tensor를 할당하려면 OpKernelConstruction/OpKernelContext의 allocate_* 메서드를 사용하십시오. 이 메서드는 커널과 스텝을 기록합니다.

기본 버퍼는 CPUAllocator 사용하여 할당됩니다.

텐서

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

지정된 입력 type 과 shape 가진 텐서를 생성하고, 할당자 a 사용하여 기본 버퍼를 할당합니다.

LogMemory::IsEnabled()가 호출되면 할당된 메모리가 알 수 없는 커널과 스텝에서 발생한 것으로 기록됩니다. Op 내에서 Tensor 생성자를 직접 호출하는 것은 더 이상 권장되지 않습니다. 새 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를 true로 설정하고 텐서 생성 후 LogMemory::RecordTensorAllocation을 호출해야 합니다. Op 내부에서 Tensor 생성자를 직접 호출하는 것은 더 이상 권장되지 않습니다. 대신 OpKernelConstruction/OpKernelContext의 allocate_* 메서드를 사용하여 커널과 스텝을 기록하는 새로운 텐서를 할당하십시오.

이 텐서 의 수명보다 오래 살아남 a 합니다.

텐서

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

입력 데이터 유형, 모양 및 버퍼를 사용하여 텐서를 생성합니다.

이 텐서 에 속하는 buf에 대한 참조를 획득합니다.

텐서

 Tensor(
  DataType type
)

지정된 데이터 유형의 빈 텐서를 생성합니다.

Tensor() 와 마찬가지로 IsInitialized() 가 True를 반환하는 1차원, 0개 요소 Tensor를 반환합니다. 자세한 내용은 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을 사용하고 반환된 Status를 확인하세요.

비트캐스팅된 모양

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

텐서 데이터를 new_sizes 에 지정된 새 모양과 새 데이터 유형 T 로 캐스팅된 Eigen::Tensor 로 반환합니다.

비트캐스트는 이동 및 복사 작업에 유용합니다. 허용되는 비트캐스트만 shaped() 함수와 다릅니다.

비트캐스팅된 모양

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

텐서 데이터를 new_sizes 에 지정된 새 모양과 새 데이터 유형 T 로 캐스팅된 Eigen::Tensor 로 반환합니다.

비트캐스트는 이동 및 복사 작업에 유용합니다. 허용되는 비트캐스트만 shaped() 함수와 다릅니다.

비트 캐스팅된 텐서

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

텐서 데이터를 지정된 데이터 유형 T 로 비트 단위로 형변환하여 동일한 크기의 Eigen::Tensor 로 반환합니다.

비트캐스트는 이동 및 복사 작업에 유용합니다. 참고: 이는 비트캐스트가 허용된다는 점을 제외하면 tensor() 와 동일합니다.

비트 캐스팅된 텐서

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

텐서 데이터를 지정된 데이터 유형 T 로 비트 단위로 형변환하여 동일한 크기의 Eigen::Tensor 로 반환합니다.

비트캐스트는 이동 및 복사 작업에 유용합니다. 참고: 이는 비트캐스트가 허용된다는 점을 제외하면 tensor() 와 동일합니다.

데이터

void * data() const 

크기

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()

데이터를 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로 반환합니다. 이때 처음 'begin' 차원의 Tensor는 결과의 첫 번째 차원으로, 마지막 dims() - 'begin' - NDIMS 차원의 Tensor 는 결과의 마지막 차원으로 축소됩니다.

'begin' < 0이면 크기가 1인 |'begin'|개의 선행 차원이 추가됩니다. 'begin' + NDIMS > dims() 이면 크기가 1인 'begin' + NDIMS - dims() 개의 후행 차원이 추가됩니다.

평면 내부 외부 치수

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)는 원래 요소 유형의 크기 * 원래 마지막 차원의 요소 수와 같아야 합니다. 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()

텐서 데이터를 크기가 1인 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 는 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()

이 Tensor의 유형과 크기를 가진 Eigen::Tensor 형식으로 텐서 데이터를 반환합니다.

데이터 유형과 텐서의 차원 수를 알고 있고, 해당 텐서 크기에 맞춰 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 

위의 모든 메서드의 const 버전입니다.

~텐서

 ~Tensor()