Open3D (C++ API)
Public Types | Public Member Functions | Static Public Member Functions | Data Fields | Protected Member Functions | Static Protected Member Functions | Protected Attributes
open3d::TensorKey Class Reference

#include <TensorKey.h>

Public Types

enum  TensorKeyMode { TensorKeyMode::Index, TensorKeyMode::Slice, TensorKeyMode::IndexTensor }
 

Public Member Functions

TensorKeyMode GetMode () const
 Getters will check the TensorKeyMode. More...
 
int64_t GetIndex () const
 
int64_t GetStart () const
 
int64_t GetStop () const
 
int64_t GetStep () const
 
bool GetStartIsNone () const
 
bool GetStopIsNone () const
 
bool GetStepIsNone () const
 
std::shared_ptr< TensorGetIndexTensor () const
 
TensorKey UpdateWithDimSize (int64_t dim_size) const
 

Static Public Member Functions

static TensorKey Index (int64_t index)
 
static TensorKey Slice (int64_t start, int64_t stop, int64_t step)
 
static TensorKey Slice (int64_t start, int64_t stop, NoneType step)
 
static TensorKey Slice (int64_t start, NoneType stop, int64_t step)
 
static TensorKey Slice (int64_t start, NoneType stop, NoneType step)
 
static TensorKey Slice (NoneType start, int64_t stop, int64_t step)
 
static TensorKey Slice (NoneType start, int64_t stop, NoneType step)
 
static TensorKey Slice (NoneType start, NoneType stop, int64_t step)
 
static TensorKey Slice (NoneType start, NoneType stop, NoneType step)
 
static TensorKey IndexTensor (const Tensor &index_tensor)
 

Data Fields

int64_t index_ = 0
 Properties for TensorKeyMode::Index. More...
 
int64_t start_ = 0
 Properties for TensorKeyMode::Slice. More...
 
int64_t stop_ = 0
 
int64_t step_ = 0
 
bool start_is_none_ = false
 
bool stop_is_none_ = false
 
bool step_is_none_ = false
 
std::shared_ptr< Tensorindex_tensor_
 

Protected Member Functions

 TensorKey (TensorKeyMode mode, int64_t index, int64_t start, int64_t stop, int64_t step, bool start_is_none, bool stop_is_none, bool step_is_none, const Tensor &index_tensor)
 
void AssertMode (TensorKeyMode mode) const
 

Static Protected Member Functions

static TensorKey Slice (int64_t start, int64_t stop, int64_t step, bool start_is_none, bool stop_is_none, bool step_is_none)
 The fully specifiec slice factory shall not be called directly. More...
 

Protected Attributes

TensorKeyMode mode_
 Depending on the mode, some properties may or may not be used. More...
 

Detailed Description

A class to represent one of: 1) tensor index e.g. t[0], t[2] 2) tensor slice e.g. t[0:10:2], t[:-1], t[3:]

Example usage:

Tensor x({2, 3, 4}, Dtype::Float32);
// Equivalent to y = x[1, :3, 0:-1:2] in Python
Tensor y = t.GetItem({TensorKey::Index(1),
TensorKey::Slice(0, -1, 2)});

Member Enumeration Documentation

◆ TensorKeyMode

Enumerator
Index 
Slice 
IndexTensor 

Constructor & Destructor Documentation

◆ TensorKey()

open3d::TensorKey::TensorKey ( TensorKeyMode  mode,
int64_t  index,
int64_t  start,
int64_t  stop,
int64_t  step,
bool  start_is_none,
bool  stop_is_none,
bool  step_is_none,
const Tensor index_tensor 
)
protected

The fully specified constructor shall not be called directly. Use the factory functions instead.

Member Function Documentation

◆ AssertMode()

void open3d::TensorKey::AssertMode ( TensorKeyMode  mode) const
inlineprotected

◆ GetIndex()

int64_t open3d::TensorKey::GetIndex ( ) const
inline

◆ GetIndexTensor()

std::shared_ptr< Tensor > open3d::TensorKey::GetIndexTensor ( ) const

◆ GetMode()

TensorKeyMode open3d::TensorKey::GetMode ( ) const
inline

Getters will check the TensorKeyMode.

◆ GetStart()

int64_t open3d::TensorKey::GetStart ( ) const
inline

◆ GetStartIsNone()

bool open3d::TensorKey::GetStartIsNone ( ) const
inline

◆ GetStep()

int64_t open3d::TensorKey::GetStep ( ) const
inline

◆ GetStepIsNone()

bool open3d::TensorKey::GetStepIsNone ( ) const
inline

◆ GetStop()

int64_t open3d::TensorKey::GetStop ( ) const
inline

◆ GetStopIsNone()

bool open3d::TensorKey::GetStopIsNone ( ) const
inline

◆ Index()

TensorKey open3d::TensorKey::Index ( int64_t  index)
static

Construct an TensorKeyMode::Index type TensorKey. E.g. b = a[3]

◆ IndexTensor()

TensorKey open3d::TensorKey::IndexTensor ( const Tensor index_tensor)
static

Construct an TensorKeyMode::IndexTensor type TensorKey (advnced indexing).

◆ Slice() [1/9]

TensorKey open3d::TensorKey::Slice ( int64_t  start,
int64_t  stop,
int64_t  step 
)
static

Construct an TensorKeyMode::Slice type TensorKey. E.g. b = a[0:100:2]

◆ Slice() [2/9]

TensorKey open3d::TensorKey::Slice ( int64_t  start,
int64_t  stop,
NoneType  step 
)
static

◆ Slice() [3/9]

TensorKey open3d::TensorKey::Slice ( int64_t  start,
NoneType  stop,
int64_t  step 
)
static

◆ Slice() [4/9]

TensorKey open3d::TensorKey::Slice ( int64_t  start,
NoneType  stop,
NoneType  step 
)
static

◆ Slice() [5/9]

TensorKey open3d::TensorKey::Slice ( NoneType  start,
int64_t  stop,
int64_t  step 
)
static

◆ Slice() [6/9]

TensorKey open3d::TensorKey::Slice ( NoneType  start,
int64_t  stop,
NoneType  step 
)
static

◆ Slice() [7/9]

TensorKey open3d::TensorKey::Slice ( NoneType  start,
NoneType  stop,
int64_t  step 
)
static

◆ Slice() [8/9]

TensorKey open3d::TensorKey::Slice ( NoneType  start,
NoneType  stop,
NoneType  step 
)
static

◆ Slice() [9/9]

TensorKey open3d::TensorKey::Slice ( int64_t  start,
int64_t  stop,
int64_t  step,
bool  start_is_none,
bool  stop_is_none,
bool  step_is_none 
)
staticprotected

The fully specifiec slice factory shall not be called directly.

◆ UpdateWithDimSize()

TensorKey open3d::TensorKey::UpdateWithDimSize ( int64_t  dim_size) const

When dim_size is know, convert the slice object such that start_is_none_ == stop_is_none_ == step_is_none_ == false E.g. if t.shape == (5,), t[:4]: before compute: Slice(None, 4, None) after compute : Slice( 0, 4, 1) E.g. if t.shape == (5,), t[1:]: before compute: Slice( 1, None, None) after compute : Slice( 1, 5, 1)

Field Documentation

◆ index_

int64_t open3d::TensorKey::index_ = 0

Properties for TensorKeyMode::Index.

◆ index_tensor_

std::shared_ptr<Tensor> open3d::TensorKey::index_tensor_

Properties for TensorKeyMode::IndexTensor. To avoid circular include, the pointer type is used. The index_tensor is shallow-copied when the TensorKey constructor is called.

◆ mode_

TensorKeyMode open3d::TensorKey::mode_
protected

Depending on the mode, some properties may or may not be used.

◆ start_

int64_t open3d::TensorKey::start_ = 0

Properties for TensorKeyMode::Slice.

◆ start_is_none_

bool open3d::TensorKey::start_is_none_ = false

◆ step_

int64_t open3d::TensorKey::step_ = 0

◆ step_is_none_

bool open3d::TensorKey::step_is_none_ = false

◆ stop_

int64_t open3d::TensorKey::stop_ = 0

◆ stop_is_none_

bool open3d::TensorKey::stop_is_none_ = false

The documentation for this class was generated from the following files: