diff --git a/src/recipes/QuantRecipes.cpp b/src/recipes/QuantRecipes.cpp index 95d1e30a288ec59633887e48aaeb9d33e7a27fda..c1848828dd3aef121819547d1e82174185decdab 100644 --- a/src/recipes/QuantRecipes.cpp +++ b/src/recipes/QuantRecipes.cpp @@ -186,72 +186,3 @@ void reorderMatMulInputs(std::shared_ptr<GraphView> graphView) } } - -/* -void replaceMatMulWithFC(std::shared_ptr<GraphView> graphView) -{ - const auto matches = SinglePassGraphMatching(graphView).match("(MatMul#)"); - - for (const auto& match : matches) - { - auto matMulNode = match.graph->rootNode(); - - std::pair<bool, bool> inputsAreProducers = {false, false}; - - if (matMulNode->getParent(0)) - inputsAreProducers.first = (matMulNode->getParent(0)->type() == "Producer"); - - if (matMulNode->getParent(1)) - inputsAreProducers.second = (matMulNode->getParent(1)->type() == "Producer"); - - if (inputsAreProducers.first && inputsAreProducers.second) - { - Log::warn(" Both input nodes of MatMul operator are Producers, it should be constant folded ! "); - } - else if (inputsAreProducers.first && !inputsAreProducers.second) - { - Log::warn(" This input setup is not supported yet ! "); - } - else if (!inputsAreProducers.first && inputsAreProducers.second) - { - // If the weight tensor is of rank 2, replace the MatMul with an FC ! - - std::shared_ptr<OperatorTensor> matMulOp = std::static_pointer_cast<OperatorTensor> (matMulNode->getOperator()); - - std::shared_ptr<Tensor> weight = matMulOp->getInput(1); - - if (weight->dims().size() == 2) - { - std::size_t inChannels = weight->dims()[0]; - std::size_t outChannels = weight->dims()[1]; - - Log::notice(" ### channels = {} {} ", inChannels, outChannels); - - std::string name = matMulNode->name() + "_FC"; - - std::shared_ptr<Node> FCNode = FC(inChannels, outChannels, true, name); - - std::shared_ptr<OperatorTensor> FCOp = std::static_pointer_cast<OperatorTensor> (FCNode->getOperator()); - - // Transpose the weights - - auto transposeOp = Transpose_Op({1, 0}); - transposeOp.setDataType(weight->dataType()); - transposeOp.setBackend(weight->backend()); - - transposeOp.associateInput(0, weight); - transposeOp.forward(); - auto transposedWeight = transposeOp.getOutput(0); - - // Fill the FC weights - - *FCOp->getInput(1) = *transposedWeight; - - // Replace the MatMul with the FC - - graphView->replace({matMulNode, matMulNode->getParent(1)}, {FCNode, FCNode->getParent(1)}); - } - } - } -} -*/ \ No newline at end of file