blace.ai
blace::ml_core::BlaceIndex Struct Reference

#include <blace_index.h>

Public Member Functions

 BlaceIndex ()
 
 BlaceIndex (int64_t integer)
 
 BlaceIndex (blace::ml_core::Slice slice)
 
 BlaceIndex (blace::ops::OpP tensor)
 
bool is_none () const
 
bool is_integer () const
 
int64_t integer () const
 
bool is_slice () const
 
const blace::ml_core::Sliceslice () const
 
bool is_node_op () const
 
const blace::ops::OpP & node_op () const
 
bool operator== (const BlaceIndex &rhs) const
 
BlaceIndexType getType ()
 
blace::ml_core::Slice getSlice ()
 
blace::ops::OpP getNodeOp ()
 

Detailed Description

Struct to represent indices of a tensor along one dimension. This mirrors a subset of https://pytorch.org/cppdocs/notes/tensor_indexing.html.

Constructor & Destructor Documentation

◆ BlaceIndex() [1/4]

blace::ml_core::BlaceIndex::BlaceIndex ( )
inline

Constructs an empty index.

◆ BlaceIndex() [2/4]

blace::ml_core::BlaceIndex::BlaceIndex ( int64_t  integer)
inline

Selects one entry along dimension.

Parameters
integerThe entry to select.

◆ BlaceIndex() [3/4]

blace::ml_core::BlaceIndex::BlaceIndex ( blace::ml_core::Slice  slice)
inline

Slices a subset of a dimension.

Parameters
sliceThe slice.

◆ BlaceIndex() [4/4]

blace::ml_core::BlaceIndex::BlaceIndex ( blace::ops::OpP  tensor)
inline

Uses an node operator to select values from the input tensor. This is the lazy evaluation equivalent of tensor[torch.tensor([1, 2])].

Parameters
tensorThe node operator.

Member Function Documentation

◆ getNodeOp()

blace::ops::OpP blace::ml_core::BlaceIndex::getNodeOp ( )

Get the node operator.

Returns

◆ getSlice()

blace::ml_core::Slice blace::ml_core::BlaceIndex::getSlice ( )

Get the slice.

Returns

◆ getType()

BlaceIndexType blace::ml_core::BlaceIndex::getType ( )

Get the type of the index.

Returns

◆ integer()

int64_t blace::ml_core::BlaceIndex::integer ( ) const

Return the stored integer.

Returns

◆ is_integer()

bool blace::ml_core::BlaceIndex::is_integer ( ) const

Check if type is integer.

Returns

◆ is_node_op()

bool blace::ml_core::BlaceIndex::is_node_op ( ) const

Check if type is node op.

Returns

◆ is_none()

bool blace::ml_core::BlaceIndex::is_none ( ) const

Check if type is none.

Returns

◆ is_slice()

bool blace::ml_core::BlaceIndex::is_slice ( ) const

Check if type is slice.

Returns

◆ node_op()

const blace::ops::OpP & blace::ml_core::BlaceIndex::node_op ( ) const

Return the operator.

Returns

◆ operator==()

bool blace::ml_core::BlaceIndex::operator== ( const BlaceIndex rhs) const

Equality operator.

Parameters
rhsThe other index.
Returns

◆ slice()

const blace::ml_core::Slice & blace::ml_core::BlaceIndex::slice ( ) const

Return the slice.

Returns