Skip to content
Snippets Groups Projects
Commit 58ab5a51 authored by Benjamin Halimi's avatar Benjamin Halimi
Browse files

remove commented code

parent 9538457f
No related branches found
No related tags found
2 merge requests!49Forked from add_matmul (merged automatically),!45Add support for the MatMul operator
Pipeline #67944 passed
...@@ -186,72 +186,3 @@ void reorderMatMulInputs(std::shared_ptr<GraphView> graphView) ...@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment