Skip to content
Snippets Groups Projects

Matmul rework

Merged Houssem ROUIS requested to merge hrouis/aidge_core:matmul_rework into dev
1 file
+ 7
8
Compare changes
  • Side-by-side
  • Inline
+ 7
8
@@ -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;
Loading