Google I/O에 참여해 주셔서 감사합니다. 주문형 모든 세션 보기 주문형 시청

텐서플로:: 텐서

#include <tensor.h>

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

요약

생성자와 소멸자

Tensor ()
1차원, 요소가 없는 float 텐서를 생성합니다.
Tensor (DataType type, const TensorShape & shape)
주어진 typeshapeTensor 를 만듭니다.
Tensor (Allocator *a, DataType type, const TensorShape & shape)
기본 버퍼를 할당하기 위해 할당자 a 를 사용하여 입력 typeshape 으로 텐서를 만듭니다.
Tensor (Allocator *a, DataType type, const TensorShape & shape, const AllocationAttributes & allocation_attr)
기본 버퍼를 할당하기 위해 할당자 a 와 지정된 "allocation_attr"을 사용하여 입력 typeshape 으로 텐서를 만듭니다.
Tensor (DataType type, const TensorShape & shape, TensorBuffer *buf)
입력 데이터 유형, 모양 및 buf를 사용하여 텐서를 생성합니다.
Tensor (DataType type)
주어진 데이터 유형의 빈 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)
이동 생성자.
~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
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
필요한 경우 이 Tensor 가 초기화되었습니까?
IsSameSize (const Tensor & b) const
bool
NumElements () const
int64
텐서 셰이프에 대한 편리한 접근자입니다.
SharesBufferWith (const Tensor & b) const
bool
Slice (int64 dim0_start, int64 dim0_limit) const
1차원을 따라 이 텐서를 슬라이스합니다.
SubSlice (int64 index) const
1차원을 따라 이 텐서에서 서브슬라이스를 선택합니다.
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로 반환하고 모든 Tensor 차원을 축소하지만 첫 번째 NDIMS-1은 결과의 마지막 차원으로 축소합니다.
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 의 유형과 크기와 함께 Eigen::Tensor 로 반환합니다.
vec () const
TTypes< T >::ConstVec
위의 모든 메서드의 const 버전입니다.

공공 기능

할당된 바이트

size_t AllocatedBytes() const 

AsProtoField

void AsProtoField(
  TensorProto *proto
) const 

*this 텐서의 내용으로 proto 를 채웁니다.

AsProtoField() 는 proto.dtype() 의 반복 필드를 채우고 proto.dtype() () 는 proto.tensor_content() AsProtoTensorContent() 의 콘텐츠를 압축된 형식으로 인코딩합니다.

AsProtoTensorContent

void AsProtoTensorContent(
  TensorProto *proto
) const 

BitcastFrom

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

다른 텐서를 이 텐서에 복사하고 모양을 변경하고 버퍼의 데이터 유형을 다시 해석합니다.

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

이 호출은 other 텐서와 주어진 유형 및 모양이 "호환"되어야 함(즉, 동일한 바이트 수를 차지함)을 요구합니다.

구체적으로:

shape.num_elements() * DataTypeSize(유형)

같아야 한다

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

또한 이 기능에는 다음이 필요합니다.

  • DataTypeSize(other.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 

이 텐서가 정렬되면 true를 반환합니다.

초기화됨

bool IsInitialized() const 

필요한 경우 이 Tensor 가 초기화되었습니까?

요소가 없는 텐서는 할당된 적이 없고 메모리가 할당되지 않은 경우에도 항상 초기화된 것으로 간주됩니다.

같은 크기

bool IsSameSize(
  const Tensor & b
) const 

NumElements

int64 NumElements() const 

텐서 셰이프에 대한 편리한 접근자입니다.

SharesBufferWith

bool SharesBufferWith(
  const Tensor & b
) const 

일부분

Tensor Slice(
  int64 dim0_start,
  int64 dim0_limit
) const 

1차원을 따라 이 텐서를 슬라이스합니다.

즉, 반환된 텐서는 반환된[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 

1차원을 따라 이 텐서에서 서브슬라이스를 선택합니다.

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

1차원, 요소가 없는 float 텐서를 생성합니다.

반환된 Tensor 는 스칼라(모양 {})가 아니라 대신 빈 1차원 Tensor (모양 {0}, NumElements() == 0)입니다. 요소가 없으므로 값을 할당할 필요가 없으며 기본적으로 초기화됩니다( IsInitialized() 는 true임). 이것이 바람직하지 않은 경우 초기화가 필요한 단일 요소 스칼라 생성을 고려하십시오.

Tensor(DT_FLOAT, TensorShape({}))

      

Tensor

 Tensor(
  DataType type,
  const TensorShape & shape
)

주어진 typeshapeTensor 를 만듭니다.

LogMemory::IsEnabled()인 경우 할당이 알 수 없는 커널 및 단계에서 오는 것으로 기록됩니다. Op 내에서 직접 Tensor 생성자를 호출하는 것은 더 이상 사용되지 않습니다. OpKernelConstruction/OpKernelContext assign_* 메서드를 사용하여 커널과 단계를 기록하는 새 텐서를 할당합니다.

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

텐서

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

기본 버퍼를 할당하기 위해 할당자 a 를 사용하여 입력 typeshape 으로 텐서를 만듭니다.

LogMemory::IsEnabled()인 경우 할당이 알 수 없는 커널 및 단계에서 오는 것으로 기록됩니다. Op 내에서 직접 Tensor 생성자를 호출하는 것은 더 이상 사용되지 않습니다. OpKernelConstruction/OpKernelContext assign_* 메서드를 사용하여 커널과 단계를 기록하는 새 텐서를 할당합니다.

Tensor a 수명보다 오래 지속되어야 합니다.

텐서

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

기본 버퍼를 할당하기 위해 할당자 a 와 지정된 "allocation_attr"을 사용하여 입력 typeshape 으로 텐서를 만듭니다.

커널과 단계가 알려진 경우 allocation_attr.allocation_will_be_logged는 true로 설정되어야 하고 LogMemory::RecordTensorAllocation은 텐서가 구성된 후에 호출되어야 합니다. Op 내에서 직접 Tensor 생성자를 호출하는 것은 더 이상 사용되지 않습니다. OpKernelConstruction/OpKernelContext assign_* 메서드를 사용하여 커널과 단계를 기록하는 새 텐서를 할당합니다.

Tensor a 수명보다 오래 지속되어야 합니다.

텐서

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

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

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

텐서

 Tensor(
  DataType type
)

주어진 데이터 유형의 빈 Tensor 를 생성합니다.

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
)

이동 생성자.

이 통화 후, 안전하게 파괴할 수 있고 에 할당할 수 있지만 이에 대한 다른 호출(예: 모양 조작)은 유효하지 않습니다.

TotalBytes

size_t TotalBytes() const 

이 텐서의 예상 메모리 사용량을 반환합니다.

UnsafeCopyFromInternal

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

BitcastFrom과 비슷하지만 전제 조건이 충족되지 않으면 CHECK가 실패합니다.

더 이상 사용되지 않습니다. 대신 BitcastFrom을 사용하고 반환된 Status 를 확인하십시오.

bit_casted_shaped

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

텐서 데이터를 new_sizes 에 지정된 새 모양으로 Eigen::Tensor 에 반환하고 새 dtype T 로 캐스트합니다.

비트캐스트를 사용하면 이동 및 복사 작업에 유용합니다. 허용되는 비트캐스트는 shaped() 과의 유일한 차이점입니다.

bit_casted_shaped

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

텐서 데이터를 new_sizes 에 지정된 새 모양으로 Eigen::Tensor 에 반환하고 새 dtype T 로 캐스트합니다.

비트캐스트를 사용하면 이동 및 복사 작업에 유용합니다. 허용되는 비트캐스트는 shaped() 과의 유일한 차이점입니다.

bit_casted_tensor

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

텐서 데이터를 동일한 크기로 Eigen::Tensor 에 반환하지만 지정된 dtype T 로 비트 캐스트합니다.

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

bit_casted_tensor

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

텐서 데이터를 동일한 크기로 Eigen::Tensor 에 반환하지만 지정된 dtype T 로 비트 캐스트합니다.

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

희미한 크기

int64 dim_size(
  int d
) const 

텐서 셰이프에 대한 편리한 접근자입니다.

희미하다

int dims() const 

텐서 셰이프에 대한 편리한 접근자입니다.

모든 모양 접근 TensorShape 에서 tensor_shape.h 의 관련 메서드에 대한 주석을 참조하세요.

dtype

DataType dtype() const 

데이터 유형을 반환합니다.

평평한

TTypes< T >::Flat flat()

텐서 데이터를 데이터 유형 및 지정된 모양의 Eigen::Tensor 로 반환합니다.

이러한 방법을 사용하면 원하는 치수와 크기로 데이터에 액세스할 수 있습니다. 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 

flat_inner_dims

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

데이터를 NDIMS 차원이 있는 Eigen::Tensor로 반환하고 마지막 NDIMS-1을 제외한 모든 Tensor 차원을 결과의 첫 번째 차원으로 축소합니다.

NDIMS > dims() 이면 크기 1의 선행 차원이 추가되어 출력 순위가 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
)

데이터를 NDIMS 차원이 있는 Eigen::Tensor로 반환하고 첫 번째 '시작' Tensor 차원을 결과의 첫 번째 차원으로 축소하고 마지막 dims() - 'begin' - NDIMS의 Tensor 차원을 마지막 차원으로 축소합니다. 결과.

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

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

데이터를 NDIMS 차원이 있는 Eigen::Tensor로 반환하고 모든 Tensor 차원을 축소하지만 첫 번째 NDIMS-1은 결과의 마지막 차원으로 축소합니다.

NDIMS > dims() 이면 크기 1의 후행 차원이 추가되어 출력 순위가 NDIMS가 됩니다.

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
)

연산자를 할당합니다. 이 텐서는 다른 사람의 기본 저장소를 공유합니다.

연산자 =

Tensor & operator=(
  Tensor && other
)

이동 연산자. 자세한 내용은 이동 생성자를 참조하세요.

reinterpret_last_dimension

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

텐서 데이터를 Eigen::Tensor 에 반환하고 마지막 차원 요소를 더 큰 유형의 단일 요소로 변환합니다.

예를 들어, 이것은 NCHW_VECT_C int8 텐서를 NCHW int32 텐서로 취급할 수 있는 커널에 유용합니다. sizeof(T)는 원래 요소 유형의 크기 * 원래 마지막 차원의 요소 수와 같아야 합니다. NDIMS는 원래 차원 수보다 1 작아야 합니다.

reinterpret_last_dimension

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

텐서 데이터를 Eigen::Tensor 에 반환하고 마지막 차원 요소를 더 큰 유형의 단일 요소로 변환합니다.

예를 들어, 이것은 NCHW_VECT_C int8 텐서를 NCHW int32 텐서로 취급할 수 있는 커널에 유용합니다. sizeof(T)는 원래 요소 유형의 크기 * 원래 마지막 차원의 요소 수와 같아야 합니다. NDIMS는 원래 차원 수보다 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 는 CPU가 직접 주소를 지정할 수 없는 장치의 메모리 위치를 가리킬 수 있습니다.

참고: 기본 텐서 버퍼는 참조 계산되므로 StringPiece 에 의해 매핑된 콘텐츠의 수명은 버퍼의 수명과 일치합니다. 호출자는 StringPiece 가 여전히 사용되는 동안 버퍼가 파괴되지 않도록 조정해야 합니다.

필요: 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 

TTypes< T >::Vec vec()

텐서 데이터를 이 Tensor의 유형과 크기와 함께 Eigen::Tensor로 반환합니다.

Tensor의 데이터 유형과 차원 수를 알고 있고 Eigen::Tensor가 Tensor 크기에 맞게 자동으로 조정되기를 원하는 경우 이 방법을 사용하십시오. 유형 또는 크기가 일치하지 않으면 구현 검사가 실패합니다.

예시:

l10n-placeholder89

l10n-placeholder90

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

~텐서

l10n-placeholder91