11 namespace optimizations
20 if (IsReshape(permute))
24 const std::string name = std::string(
"as_reshape-") + permute.
GetName();
45 const unsigned int numDimensions = permutation.
GetSize();
47 unsigned int lastGtOne = 0;
48 while ((lastGtOne < numDimensions) && (outShape[(permutation[lastGtOne])] == 1U))
53 bool isReshape =
true;
54 for (
unsigned int i = lastGtOne + 1U; isReshape && (i < numDimensions); ++i)
56 if (outShape[permutation[i]] > 1U)
58 isReshape = permutation[lastGtOne] < permutation[i];
const OutputHandler & GetOutputHandler(unsigned int i=0) const
const char * GetName() const override
const PermutationVector & GetPermutation() const
This layer represents a reshape operation.
const TensorInfo & GetTensorInfo() const
Gets the matching TensorInfo for the output.
A ReshapeDescriptor for the ReshapeLayer.
This layer represents a permutation operation.
void MoveAllConnections(OutputSlot &destination)
Moves all connections to another OutputSlot.
PermuteAsReshapeImpl()=default
~PermuteAsReshapeImpl()=default
void SetTensorInfo(const TensorInfo &tensorInfo)
Sets the TensorInfo used by this output handler.
void Run(Graph &graph, PermuteLayer &permute) const
Run for every PermuteLayer. Replaces it with a ReshapeLayer if they are equivalent.
LayerT * InsertNewLayer(InputSlot &insertBefore, Args &&... args)
const TensorShape & GetShape() const
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
const InputSlot & GetInputSlot(unsigned int index) const override