This class implements a layer that changes the input blob dimensions without moving any of the data. The total number of elements in the blob stays the same, and therefore the product of all dimensions should not be changed by the transformation.
// Modes of dimension change
enum TOperation {
// Set this dimension so that the total size stays the same
// Only one of the dimensions may have this mode
O_Remainder,
// Set this dimension to Parameter value
O_SetSize,
// Multiply this dimension by Parameter value
O_Multiply,
// Divide this dimension by Parameter value
O_Divide
};
// The rule of dimension change
struct NEOML_API CDimensionRule {
// The mode of dimension change
TOperation Operation;
// The numerical parameter to be used
int Parameter;
CDimensionRule();
CDimensionRule( TOperation op, int param );
bool operator==( const CDimensionRule& other ) const;
// Applies the transformation set by the rule
int Transform( int input ) const;
};
void SetDimensionRule( TBlobDim dim, const CDimensionRule& rule );
void SetDimensionRule( TBlobDim dim, TOperation op, int param );Sets the change that will be applied to the specified blob dimension. If you do not set any changes for one of the dimensions, it will retain its size.
Only one of the blob dimensions may have the O_Remainder mode.
There are no trainable parameters for this layer.
The single input accepts a blob of any size with data of any type.
The single output contains a blob of the dimensions determined by the specified rules:
- The dimensions with
O_SetSizemode will be equal to the specifiedParameter. - The dimensions with
O_Multiplymode will beParametertimes larger. - The dimensions with
O_Dividemode will beParametersmaller. - The dimension with
O_Remaindermode will be such that the total size of the input and the output are the same.