Cyclops Tensor Framework
parallel arithmetic on multidimensional arrays
CTF::Idx_Tensor Class Reference

a tensor with an index map associated with it (necessary for overloaded operators) More...

#include <idx_tensor.h>

Inheritance diagram for CTF::Idx_Tensor:
Collaboration diagram for CTF::Idx_Tensor:

Public Member Functions

CTF_int::Termclone (std::map< CTF_int::tensor *, CTF_int::tensor * > *remap=NULL) const
 base classes must implement this copy function to retrieve pointer More...
 
 Idx_Tensor (CTF_int::tensor *parent_, const char *idx_map_, int copy=0)
 constructor takes in a parent tensor and its indices More...
 
 Idx_Tensor (CTF::Idx_Tensor const &other, int copy=0, std::map< CTF_int::tensor *, CTF_int::tensor * > *remap=NULL)
 copy constructor More...
 
 Idx_Tensor (CTF_int::algstrct const *sr)
 constructor for scalar More...
 
 Idx_Tensor (CTF_int::algstrct const *sr, double scl)
 
 Idx_Tensor (CTF_int::algstrct const *sr, int64_t scl)
 
 ~Idx_Tensor ()
 
Idx_Tensor execute (std::vector< char > out_inds) const
 evalues the expression to produce an intermediate with all expression indices remaining More...
 
void execute (Idx_Tensor output) const
 evalues the expression, which just scales by default More...
 
double estimate_time (Idx_Tensor output) const
 estimates the cost of a contraction More...
 
Idx_Tensor estimate_time (double &cost, std::vector< char > out_inds) const
 estimates the cost the expression to produce an intermediate with all expression indices remaining More...
 
std::vector< char > get_uniq_inds () const
 find list of unique indices that are involved in this term More...
 
void get_inputs (std::set< Idx_Tensor *, CTF_int::tensor_name_less > *inputs_set) const
 appends the tensors this depends on to the input set More...
 
void operator= (CTF_int::Term const &B)
 A = B, compute any operations on operand B and set. More...
 
void operator= (Idx_Tensor const &B)
 
void operator= (double scl)
 
void operator+= (double scl)
 
void operator-= (double scl)
 
void operator*= (double scl)
 
void multeq (double scl)
 
void operator= (int64_t scl)
 
void operator+= (int64_t scl)
 
void operator-= (int64_t scl)
 
void operator*= (int64_t scl)
 
void operator= (int scl)
 
void operator+= (int scl)
 
void operator-= (int scl)
 
void operator*= (int scl)
 
void operator+= (CTF_int::Term const &B)
 A += B, compute any operations on operand B and add. More...
 
void operator-= (CTF_int::Term const &B)
 A += B, compute any operations on operand B and add. More...
 
void operator*= (CTF_int::Term const &B)
 negates term More...
 
Worldwhere_am_i () const
 figures out what world this term lives on More...
 
- Public Member Functions inherited from CTF_int::Term
 Term (algstrct const *sr)
 
virtual ~Term ()
 
virtual void get_inputs (std::set< CTF::Idx_Tensor *, tensor_name_less > *inputs_set) const =0
 appends the tensors this depends on to the input set More...
 
void mult_scl (char const *mulscl)
 multiply scaling factor by mulscl More...
 
Contract_Term operator* (Term const &A) const
 constructs a new term which multiplies by tensor A More...
 
Contract_Term operator* (int64_t scl) const
 multiples by a constant More...
 
Contract_Term operator* (double scl) const
 
Sum_Term operator+ (Term const &A) const
 constructs a new term by addition of two terms More...
 
Sum_Term operator+ (double scl) const
 
Sum_Term operator+ (int64_t scl) const
 
Sum_Term operator- (Term const &A) const
 constructs a new term by subtracting term A More...
 
Sum_Term operator- (double scl) const
 
Sum_Term operator- (int64_t scl) const
 
Termoperator- ()
 
void operator= (CTF::Idx_Tensor const &B)
 A = B, compute any operations on operand B and set. More...
 
void operator= (Term const &B)
 
void operator+= (Term const &B)
 
void operator-= (Term const &B)
 
void operator*= (Term const &B)
 
void operator= (double scl)
 
void operator+= (double scl)
 
void operator<< (CTF_int::Term const &B)
 
void operator<< (double scl)
 
void operator-= (double scl)
 
void operator*= (double scl)
 
void operator= (int64_t scl)
 
void operator+= (int64_t scl)
 
void operator-= (int64_t scl)
 
void operator*= (int64_t scl)
 
void operator= (int scl)
 
void operator+= (int scl)
 
void operator-= (int scl)
 
void operator*= (int scl)
 
 operator float () const
 cast to float (works only if tensor type is castable to float) allows a scalar output More...
 
 operator double () const
 cast to double (works only if tensor type is castable to double) allows a scalar output More...
 
 operator int64_t () const
 cast to int64_t (works only if tensor type is castable to int64_t) allows a scalar output More...
 
 operator int () const
 cast to int64_t (works only if tensor type is castable to int64_t) allows a scalar output More...
 

Data Fields

CTF_int::tensorparent
 
char * idx_map
 
int is_intm
 
- Data Fields inherited from CTF_int::Term
char * scale
 
algstrctsr
 

Detailed Description

a tensor with an index map associated with it (necessary for overloaded operators)

Definition at line 15 of file idx_tensor.h.

Constructor & Destructor Documentation

CTF::Idx_Tensor::Idx_Tensor ( CTF_int::tensor parent_,
const char *  idx_map_,
int  copy = 0 
)

constructor takes in a parent tensor and its indices

Parameters
[in]parent_the parent tensor
[in]idx_map_the indices assigned ot this tensor
[in]copyif set to 1, create copy of parent

Definition at line 83 of file idx_tensor.cxx.

References CTF_int::alloc(), idx_map, is_intm, CTF_int::tensor::order, and parent.

Referenced by clone(), multeq(), operator*=(), operator+=(), operator-=(), and operator=().

CTF::Idx_Tensor::Idx_Tensor ( CTF::Idx_Tensor const &  other,
int  copy = 0,
std::map< CTF_int::tensor *, CTF_int::tensor * > *  remap = NULL 
)

copy constructor

Parameters
[in]othertensor to copy
[in]copyif 1 then copy the parent tensor of B into a new tensor
[in]remapredistribution dependency map

Definition at line 116 of file idx_tensor.cxx.

References CTF_int::alloc(), idx_map, is_intm, ctf.core::it, CTF_int::tensor::order, parent, CTF_int::algstrct::safecopy(), CTF_int::Term::scale, and CTF_int::Term::sr.

CTF::Idx_Tensor::Idx_Tensor ( CTF_int::algstrct const *  sr)

constructor for scalar

Parameters
[in]srring/semiring

Definition at line 96 of file idx_tensor.cxx.

References idx_map, is_intm, and parent.

CTF::Idx_Tensor::Idx_Tensor ( CTF_int::algstrct const *  sr,
double  scl 
)
CTF::Idx_Tensor::Idx_Tensor ( CTF_int::algstrct const *  sr,
int64_t  scl 
)
CTF::Idx_Tensor::~Idx_Tensor ( )

Definition at line 159 of file idx_tensor.cxx.

References CTF_int::cdealloc(), idx_map, is_intm, and parent.

Member Function Documentation

Term * CTF::Idx_Tensor::clone ( std::map< CTF_int::tensor *, CTF_int::tensor * > *  remap = NULL) const
virtual

base classes must implement this copy function to retrieve pointer

Implements CTF_int::Term.

Reimplemented in CTF::Typ_Idx_Tensor< dtype >, and CTF::Typ_Idx_Tensor< dtype_C >.

Definition at line 168 of file idx_tensor.cxx.

References Idx_Tensor().

Referenced by CTF_int::contract_down_terms(), CTF::TensorOperation::execute(), and CTF_int::Term::operator*().

double CTF::Idx_Tensor::estimate_time ( Idx_Tensor  output) const
virtual

estimates the cost of a contraction

Parameters
[in]outputtensor to write results into and its indices

Implements CTF_int::Term.

Definition at line 294 of file idx_tensor.cxx.

References CTF_int::summation::estimate_time(), idx_map, CTF_int::algstrct::mulid(), parent, CTF_int::Term::scale, CTF_int::Term::sr, and where_am_i().

Referenced by CTF_int::Sum_Term::estimate_time(), and CTF_int::Contract_Term::estimate_time().

Idx_Tensor CTF::Idx_Tensor::estimate_time ( double &  cost,
std::vector< char >  out_inds 
) const
virtual

estimates the cost the expression to produce an intermediate with all expression indices remaining

Parameters
[out]costestimate of time in sec
[in]out_indsunique indices to not contract/sum away

Implements CTF_int::Term.

Definition at line 307 of file idx_tensor.cxx.

Idx_Tensor CTF::Idx_Tensor::execute ( std::vector< char >  out_inds) const
virtual

evalues the expression to produce an intermediate with all expression indices remaining

Parameters
[in]out_indsunique indices to not contract/sum away
Returns
output tensor to write results into and its indices

Implements CTF_int::Term.

Definition at line 290 of file idx_tensor.cxx.

Referenced by CTF_int::Sum_Term::execute(), CTF_int::Contract_Term::execute(), multeq(), CTF::Typ_Sum_Term< dtype_A, dtype_B >::operator()(), operator*=(), operator+=(), CTF::Typ_Sum_Term< dtype_A, dtype_B >::operator,(), operator-=(), and operator=().

void CTF::Idx_Tensor::execute ( Idx_Tensor  output) const
virtual

evalues the expression, which just scales by default

Parameters
[in,out]outputtensor to write results into and its indices

Implements CTF_int::Term.

Definition at line 270 of file idx_tensor.cxx.

References CTF_int::summation::execute(), CTF_int::tensor::get_raw_data(), idx_map, parent, CTF_int::Term::scale, CTF_int::Term::sr, and where_am_i().

void CTF::Idx_Tensor::get_inputs ( std::set< Idx_Tensor *, CTF_int::tensor_name_less > *  inputs_set) const

appends the tensors this depends on to the input set

Definition at line 320 of file idx_tensor.cxx.

std::vector< char > CTF::Idx_Tensor::get_uniq_inds ( ) const
virtual
void CTF::Idx_Tensor::multeq ( double  scl)

Definition at line 222 of file idx_tensor.cxx.

References execute(), get_uniq_inds(), Idx_Tensor(), and CTF_int::Term::sr.

void CTF::Idx_Tensor::operator*= ( double  scl)

Definition at line 221 of file idx_tensor.cxx.

References execute(), get_uniq_inds(), Idx_Tensor(), and CTF_int::Term::sr.

void CTF::Idx_Tensor::operator*= ( int64_t  scl)

Definition at line 227 of file idx_tensor.cxx.

References execute(), get_uniq_inds(), Idx_Tensor(), and CTF_int::Term::sr.

void CTF::Idx_Tensor::operator*= ( int  scl)

Definition at line 232 of file idx_tensor.cxx.

References execute(), get_uniq_inds(), Idx_Tensor(), and CTF_int::Term::sr.

void CTF::Idx_Tensor::operator*= ( CTF_int::Term const &  B)

negates term

A -> A*B contract two tensors

Parameters
[in]Btensor on the right hand side

Definition at line 257 of file idx_tensor.cxx.

References CTF::ScheduleBase::add_operation(), CTF_int::Term::clone(), CTF::global_schedule, Idx_Tensor(), and CTF::TENSOR_OP_MULTIPLY.

void CTF::Idx_Tensor::operator+= ( double  scl)
void CTF::Idx_Tensor::operator+= ( int64_t  scl)

Definition at line 225 of file idx_tensor.cxx.

References execute(), get_uniq_inds(), Idx_Tensor(), and CTF_int::Term::sr.

void CTF::Idx_Tensor::operator+= ( int  scl)

Definition at line 230 of file idx_tensor.cxx.

References execute(), get_uniq_inds(), Idx_Tensor(), and CTF_int::Term::sr.

void CTF::Idx_Tensor::operator+= ( CTF_int::Term const &  B)

A += B, compute any operations on operand B and add.

Parameters
[in]Btensor on the right hand side

Definition at line 207 of file idx_tensor.cxx.

References CTF::ScheduleBase::add_operation(), CTF_int::Term::clone(), CTF_int::Term::execute(), CTF::global_schedule, Idx_Tensor(), CTF_int::algstrct::mulid(), CTF_int::algstrct::safecopy(), CTF_int::Term::scale, CTF_int::Term::sr, and CTF::TENSOR_OP_SUM.

void CTF::Idx_Tensor::operator-= ( double  scl)

Definition at line 220 of file idx_tensor.cxx.

References execute(), get_uniq_inds(), Idx_Tensor(), and CTF_int::Term::sr.

void CTF::Idx_Tensor::operator-= ( int64_t  scl)

Definition at line 226 of file idx_tensor.cxx.

References execute(), get_uniq_inds(), Idx_Tensor(), and CTF_int::Term::sr.

void CTF::Idx_Tensor::operator-= ( int  scl)

Definition at line 231 of file idx_tensor.cxx.

References execute(), get_uniq_inds(), Idx_Tensor(), and CTF_int::Term::sr.

void CTF::Idx_Tensor::operator= ( double  scl)

Definition at line 218 of file idx_tensor.cxx.

References execute(), get_uniq_inds(), Idx_Tensor(), and CTF_int::Term::sr.

void CTF::Idx_Tensor::operator= ( int64_t  scl)

Definition at line 224 of file idx_tensor.cxx.

References execute(), get_uniq_inds(), Idx_Tensor(), and CTF_int::Term::sr.

void CTF::Idx_Tensor::operator= ( int  scl)

Definition at line 229 of file idx_tensor.cxx.

References execute(), get_uniq_inds(), Idx_Tensor(), and CTF_int::Term::sr.

World * CTF::Idx_Tensor::where_am_i ( ) const
virtual

figures out what world this term lives on

brief TODO A -> A * B^-1 param[in] B brief execute ips into output with scale beta

Implements CTF_int::Term.

Definition at line 172 of file idx_tensor.cxx.

References parent, and CTF_int::tensor::wrld.

Referenced by estimate_time(), and execute().

Field Documentation

int CTF::Idx_Tensor::is_intm

Definition at line 19 of file idx_tensor.h.

Referenced by CTF_int::get_full_intm(), Idx_Tensor(), and ~Idx_Tensor().


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