SumDescriptor Class Referenceabstract

This is an abstract base-class. More...

#include <nnet-descriptor.h>

Inheritance diagram for SumDescriptor:

Public Member Functions

virtual void GetDependencies (const Index &ind, std::vector< Cindex > *dependencies) const =0
 Given an Index at the output of this Descriptor, append to "dependencies" a list of Cindexes that describes what inputs we potentially depend on. More...
 
virtual bool IsComputable (const Index &ind, const CindexSet &cindex_set, std::vector< Cindex > *used_inputs) const =0
 This function exists to enable us to manage optional dependencies, i.e. More...
 
virtual int32 Dim (const Nnet &nnet) const =0
 
virtual SumDescriptorCopy () const =0
 
virtual ~SumDescriptor ()
 
virtual void GetNodeDependencies (std::vector< int32 > *node_indexes) const =0
 This function appends to "node_indexes" a list (not necessarily sorted or unique) of all the node indexes that this descriptor may forward data from. More...
 
virtual BaseFloat GetScaleForNode (int32 node_index) const =0
 This function returns the scale on the node-index 'node_index' when it appears in expressions inside this descriptor. More...
 
virtual int32 Modulus () const =0
 
virtual void WriteConfig (std::ostream &os, const std::vector< std::string > &node_names) const =0
 Write in config-file format. More...
 

Detailed Description

This is an abstract base-class.

In the normal case a SumDescriptor is a sum over one or more ForwardingDescriptors (all of which must be of the same dimension). However, it also allows for logic for dealing with cases where only some terms in the sum are present, and only some are included in the sum: for example, not just expressions like A + B but also A + (B if present), or (A if present; if not, B). It also handles expressions involving adding a constant, e.g. `Sum(Scale(tdnn2, -1.0), Const(1.0, 512))` (see ConstantSumDescriptor).

Definition at line 315 of file nnet-descriptor.h.

Constructor & Destructor Documentation

◆ ~SumDescriptor()

Member Function Documentation

◆ Copy()

virtual SumDescriptor* Copy ( ) const
pure virtual

◆ Dim()

virtual int32 Dim ( const Nnet nnet) const
pure virtual

◆ GetDependencies()

virtual void GetDependencies ( const Index ind,
std::vector< Cindex > *  dependencies 
) const
pure virtual

Given an Index at the output of this Descriptor, append to "dependencies" a list of Cindexes that describes what inputs we potentially depend on.

The output list is not necessarily sorted, and this function doesn't make sure that it's unique.

Implemented in BinarySumDescriptor, ConstantSumDescriptor, SimpleSumDescriptor, and OptionalSumDescriptor.

◆ GetNodeDependencies()

virtual void GetNodeDependencies ( std::vector< int32 > *  node_indexes) const
pure virtual

This function appends to "node_indexes" a list (not necessarily sorted or unique) of all the node indexes that this descriptor may forward data from.

Implemented in BinarySumDescriptor, ConstantSumDescriptor, SimpleSumDescriptor, and OptionalSumDescriptor.

Referenced by Compiler::SplitByScale().

◆ GetScaleForNode()

virtual BaseFloat GetScaleForNode ( int32  node_index) const
pure virtual

This function returns the scale on the node-index 'node_index' when it appears in expressions inside this descriptor.

E.g. if the descriptor is just `Scale(tdnn2, 2.0)` and the node index for `tdnn2` is 4, then GetScaleForNode(4) would return 2.0. It will return +infinity if the node is >= 0 and does not appear in this descriptor. If node_index < 0, it returns the constant offset value from this descriptor, which will equal 0.0 if there is no expression like `Const(1.0, 512)` in this node. If a particular node_index > 0 appears in different sub-expressions of the descriptor with different scales it is an error (it's not supported) and this function would crash.

Implemented in BinarySumDescriptor, ConstantSumDescriptor, SimpleSumDescriptor, and OptionalSumDescriptor.

Referenced by Compiler::CompileForwardSumDescriptor(), and Compiler::SplitByScale().

◆ IsComputable()

virtual bool IsComputable ( const Index ind,
const CindexSet cindex_set,
std::vector< Cindex > *  used_inputs 
) const
pure virtual

This function exists to enable us to manage optional dependencies, i.e.

for making sense of expressions like (A + (B is present)) and (A if present; if not, B). Suppose we are trying to compute the index "ind", and the user represents that "cindex_set" is the set of Cindexes are available to the computation; then this function will return true if we can compute the expression given these inputs; and if so, will output to "used_inputs" the list of Cindexes that this expression will be a summation over.

Parameters
[in]indThe index that we want to compute at the output of the Descriptor.
[in]cindex_setThe set of Cindexes that are available at the input of the Descriptor.
[out]used_inputsIf non-NULL, if this function returns true then to this vector will be *appended* the inputs that will actually participate in the computation. Else (if non-NULL) it will be left unchanged.
Returns
Returns true if this output is computable given the provided inputs.

Implemented in BinarySumDescriptor, ConstantSumDescriptor, SimpleSumDescriptor, and OptionalSumDescriptor.

Referenced by Compiler::ComputeInputLocationsList().

◆ Modulus()

virtual int32 Modulus ( ) const
pure virtual

◆ WriteConfig()

virtual void WriteConfig ( std::ostream &  os,
const std::vector< std::string > &  node_names 
) const
pure virtual

Write in config-file format.

Conventional Read and Write methods are not supported.

Implemented in BinarySumDescriptor, ConstantSumDescriptor, SimpleSumDescriptor, and OptionalSumDescriptor.


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