From e47b900df9783f30e4731dfe1472d2cb6d865720 Mon Sep 17 00:00:00 2001 From: hrouis <houssemeddine.rouis92@gmail.com> Date: Fri, 9 Feb 2024 13:38:06 +0100 Subject: [PATCH] minor cleanups --- src/operator/MatMul.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/operator/MatMul.cpp b/src/operator/MatMul.cpp index 4bb54e83b..4e35ba093 100644 --- a/src/operator/MatMul.cpp +++ b/src/operator/MatMul.cpp @@ -20,6 +20,9 @@ const std::string Aidge::MatMul_Op::Type = "MatMul"; 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()) { const auto dims0 = getInput(0)->dims(); @@ -27,18 +30,14 @@ void Aidge::MatMul_Op::computeOutputDims() { if (dims0.size() > 2 && dims1.size() > 2) { - bool supportedSizes = true; 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]) - supportedSizes = false; - - d0--; - d1--; + AIDGE_THROW_OR_ABORT(std::runtime_error, "Unsupported sizes for MatMul!"); } - 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; -- GitLab