MagmaDNN  1.0
c++NeuralNetworkFramework
magmadnn::op::Operation< T > Class Template Referenceabstract
Inheritance diagram for magmadnn::op::Operation< T >:
Collaboration diagram for magmadnn::op::Operation< T >:

Public Member Functions

 Operation ()
 
 Operation (std::vector< Operation< T > *> inputs, bool needs_grad=true)
 
virtual std::vector< unsigned int > get_output_shape () const
 
virtual unsigned int get_output_shape (unsigned int idx) const
 
virtual unsigned int get_output_size () const
 
virtual memory_t get_memory_type () const
 
virtual Tensor< T > * eval (bool recompute=true)
 
virtual void reset ()
 
virtual Tensor< T > * grad (Operation< T > *consumer, Operation< T > *var, Tensor< T > *grad, bool recompute=true)
 
virtual void add_consumer (Operation< T > *consumer)
 
virtual std::vector< Operation< T > * > get_consumers ()
 
virtual std::vector< Operation< T > * > get_inputs ()
 
virtual Tensor< T > * get_output_tensor ()
 
virtual Tensor< T > * get_grad_tensor (Operation< T > *wrt)
 
virtual std::string to_string ()=0
 
virtual std::string get_name ()
 

Protected Member Functions

virtual Tensor< T > * _eval (bool recompute=true)=0
 
virtual Tensor< T > * _grad (Operation< T > *consumer, Operation< T > *var, Tensor< T > *grad)=0
 

Protected Attributes

std::vector< Operation< T > * > inputs
 
std::vector< Operation< T > * > consumers
 
std::vector< unsigned int > output_shape
 
memory_t mem_type
 
std::map< uintptr_t, Tensor< T > * > _grad_cache
 
std::string name = "DefaultOpName"
 
Tensor< T > * output_tensor
 
bool needs_grad
 
bool has_been_computed
 
bool has_grad_been_computed
 

Constructor & Destructor Documentation

◆ Operation()

template<typename T>
magmadnn::op::Operation< T >::Operation ( )
inline

The operation class serves as an abstract object, which all tensors operations descend from. It is used to build a computation tree.

Member Function Documentation

◆ _eval()

◆ _grad()

◆ add_consumer()

template<typename T>
virtual void magmadnn::op::Operation< T >::add_consumer ( Operation< T > *  consumer)
inlinevirtual
Parameters
consumer

◆ eval()

template<typename T>
virtual Tensor<T>* magmadnn::op::Operation< T >::eval ( bool  recompute = true)
inlinevirtual

Returns the operation's evaluated tensor.

Parameters
recomputewhether to use previous value or recalculate
Returns
Tensor<T>*
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_consumers()

template<typename T>
virtual std::vector<Operation<T> *> magmadnn::op::Operation< T >::get_consumers ( )
inlinevirtual

Returns a vector of operations that need this operation as input.

Returns
std::vector<Operation<T> *> vector of consumer operations

◆ get_grad_tensor()

template<typename T>
virtual Tensor<T>* magmadnn::op::Operation< T >::get_grad_tensor ( Operation< T > *  wrt)
inlinevirtual

Gets the current grad_tensor wrt to wrt.

Parameters
wrt
Returns
Tensor<T>*
Here is the call graph for this function:

◆ get_inputs()

template<typename T>
virtual std::vector<Operation<T> *> magmadnn::op::Operation< T >::get_inputs ( )
inlinevirtual

Returns a vector the input operations to this one.

Returns
std::vector<Operation<T> *> vector of input operations

◆ get_memory_type()

template<typename T>
virtual memory_t magmadnn::op::Operation< T >::get_memory_type ( ) const
inlinevirtual

The memory type used to compute this operation.

Returns
memory_t

◆ get_name()

template<typename T>
virtual std::string magmadnn::op::Operation< T >::get_name ( )
inlinevirtual

the name of this operation.

Returns
std::string

Reimplemented in magmadnn::op::Variable< T >.

Here is the call graph for this function:

◆ get_output_shape() [1/2]

template<typename T>
virtual std::vector<unsigned int> magmadnn::op::Operation< T >::get_output_shape ( ) const
inlinevirtual

Returns the expected output shape of this operation.

Returns
std::vector<unsigned int>

◆ get_output_shape() [2/2]

template<typename T>
virtual unsigned int magmadnn::op::Operation< T >::get_output_shape ( unsigned int  idx) const
inlinevirtual
Parameters
idx
Returns
std::vector<unsigned int>

◆ get_output_size()

template<typename T>
virtual unsigned int magmadnn::op::Operation< T >::get_output_size ( ) const
inlinevirtual

The total number of elements outputted by operation.

Returns
unsigned int

◆ get_output_tensor()

template<typename T>
virtual Tensor<T>* magmadnn::op::Operation< T >::get_output_tensor ( )
inlinevirtual

Gets a pointer to the output tensor this returns

Returns
Tensor<T>*

◆ grad()

template<typename T>
virtual Tensor<T>* magmadnn::op::Operation< T >::grad ( Operation< T > *  consumer,
Operation< T > *  var,
Tensor< T > *  grad,
bool  recompute = true 
)
inlinevirtual

Computes the gradient with respect to the outputs and var.

Parameters
consumerthe operation that consumes this that needs the gradient
gradthe gradient of the loss w.r.t. the consumers output
Returns
Tensor<T>*
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

template<typename T>
virtual void magmadnn::op::Operation< T >::reset ( )
inlinevirtual

Clears the operation so that it will be recomputed.

◆ to_string()


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