텐서플로우:: 텐서

#include <tensor.h>

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

요약

생성자와 소멸자

Tensor ()
1차원, 요소가 0개인 부동 소수점 텐서를 생성합니다.
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 proto를 채웁니다.
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
텐서 데이터를 크기는 동일하지만 지정된 dtype T 로 비트 단위 변환된 Eigen::Tensor 로 반환합니다.
bit_casted_tensor () const
TTypes< T, NDIMS >::ConstTensor
텐서 데이터를 크기는 동일하지만 지정된 dtype 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
데이터를 NDIMS 차원이 있는 Eigen::Tensor로 반환합니다. 첫 번째 '시작' Tensor 차원을 결과의 첫 번째 차원으로 축소하고 마지막 darks() - '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 데이터를 고정된 크기의 TensorMap 으로 반환합니다. 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 

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

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

AsProtoTensorContent

void AsProtoTensorContent(
  TensorProto *proto
) const 

비트캐스트From

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

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

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

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

구체적으로:

모양.num_elements() * DataTypeSize(유형)

같아야 합니다

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

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

  • DataTypeSize(other.dtype()) != 0
  • 데이터유형크기(유형) != 0

요구 사항 중 하나라도 충족되지 않으면 오류::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 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 

필요한 경우 이 Tensor가 초기화되었나요?

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

동일크기

bool IsSameSize(
  const Tensor & b
) const 

요소 수

int64 NumElements() const 

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

SharesBufferWith

bool SharesBufferWith(
  const Tensor & b
) const 

일부분

Tensor Slice(
  int64 dim0_start,
  int64 dim0_limit
) const 

이 텐서를 1차원으로 분할합니다.

즉, 반환된 텐서는 return[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차원, 요소가 0개인 부동 소수점 텐서를 생성합니다.

반환된 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 할당_* 메소드를 사용하여 커널과 단계를 기록하는 새 텐서를 할당합니다.

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

텐서

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

기본 버퍼를 할당하기 위해 할당자 a 를 사용하여 입력 typeshape 있는 텐서를 생성합니다.

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

aTensor 의 수명보다 오래 지속되어야 합니다.

텐서

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

기본 버퍼를 할당하기 위해 할당자 a 와 지정된 "allocation_attr"을 사용하여 입력 typeshape 가진 텐서를 생성합니다.

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

aTensor 의 수명보다 오래 지속되어야 합니다.

텐서

 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
)

생성자를 이동합니다.

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

총바이트

size_t TotalBytes() const 

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

안전하지 않은CopyFrom내부

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

텐서 데이터를 크기는 동일하지만 지정된 dtype T 로 비트 단위 변환된 Eigen::Tensor 로 반환합니다.

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

비트캐스트_텐서

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

텐서 데이터를 크기는 동일하지만 지정된 dtype T 로 비트 단위 변환된 Eigen::Tensor 로 반환합니다.

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

희미한 크기

int64 dim_size(
  int d
) const 

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

어두워지다

int dims() const 

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

모든 모양 접근자에 대해서는 tensor_shape.hTensorShape 관련 메서드에 대한 주석을 참조하세요.

dtype

DataType dtype() const 

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

평평한

TTypes< T >::Flat flat()

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

이러한 방법을 사용하면 선택한 치수와 크기의 데이터에 액세스할 수 있습니다. Tensor 를 호출하기 위해 Tensor의 차원 수를 알 필요는 없습니다. 그러나 유형이 일치하고 요청된 차원이 텐서와 동일한 수의 요소를 가진 Eigen::Tensor 생성하는지 CHECK .

예:

  
    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 > 희미한() 경우 크기 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 차원을 결과의 첫 번째 차원으로 축소하고 마지막 darks() - 'begin' - NDIMS의 Tensor 차원을 결과의 마지막 차원으로 축소합니다. 결과.

'시작' < 0이면 |'시작'| 크기 1의 선행 치수가 추가됩니다. 'begin' + NDIMS > 희미한 () 경우 'begin' + NDIMS - 크기 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로 반환하고 첫 번째 NDIMS-1을 제외한 모든 Tensor 차원을 결과의 마지막 차원으로 축소합니다.

NDIMS > 희미한() 경우 크기 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 데이터를 고정된 크기의 TensorMap 으로 반환합니다. 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 

vec

TTypes< T >::Vec vec()

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

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

예:

l10n-자리 표시자89

l10n-자리 표시자90

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

~텐서

l10n-자리 표시자91