Skip to content
Snippets Groups Projects
Commit b096e315 authored by Houssem ROUIS's avatar Houssem ROUIS
Browse files

minor cleanups

parent 887249ac
No related branches found
No related tags found
2 merge requests!105version 0.2.0,!76Matmul rework
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
const std::string Aidge::MatMul_Op::Type = "MatMul"; const std::string Aidge::MatMul_Op::Type = "MatMul";
void Aidge::MatMul_Op::computeOutputDims() { void Aidge::MatMul_Op::computeOutputDims() {
if (!getInput(0) || !getInput(1)) {
AIDGE_THROW_OR_ABORT(std::runtime_error, "Missing input. Cannot compute output dimensions for MatMul Operator.");
}
if (!getInput(0)->empty() && !getInput(1)->empty()) if (!getInput(0)->empty() && !getInput(1)->empty())
{ {
const auto dims0 = getInput(0)->dims(); const auto dims0 = getInput(0)->dims();
...@@ -27,18 +30,14 @@ void Aidge::MatMul_Op::computeOutputDims() { ...@@ -27,18 +30,14 @@ void Aidge::MatMul_Op::computeOutputDims() {
if (dims0.size() > 2 && dims1.size() > 2) if (dims0.size() > 2 && dims1.size() > 2)
{ {
bool supportedSizes = true;
std::size_t d0 = dims0.size()-3, d1 = dims1.size()-3; std::size_t d0 = dims0.size()-3, d1 = dims1.size()-3;
while(d0>0 && d1>0 && supportedSizes) for (std::size_t d0 = dims0.size()-3, d1 = dims1.size()-3;
(d0>0) && (d1>0);
--d0, --d1)
{ {
if(dims0[d0] != dims1[d1]) if(dims0[d0] != dims1[d1])
supportedSizes = false; AIDGE_THROW_OR_ABORT(std::runtime_error, "Unsupported sizes for MatMul!");
d0--;
d1--;
} }
if(!supportedSizes)
AIDGE_THROW_OR_ABORT(std::runtime_error, "Unsupported sizes for MatMul!");
} }
std::size_t secondToLastIdx2 = dims1.size()>1 ? dims1.size() - 2 : dims1.size() - 1; std::size_t secondToLastIdx2 = dims1.size()>1 ? dims1.size() - 2 : dims1.size() - 1;
......
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