1d support for einsum

This commit is contained in:
Abduragim 2024-01-08 21:34:47 +03:00
parent bae435a5a7
commit 6c28d7140a
2 changed files with 5 additions and 5 deletions

View File

@ -105,7 +105,7 @@ static Mat batchwiseMatMul(
// input1 should of size MxK
// check if input1 needs reshape, if need reshape
if (input1.dims > 2 || input1.size[0] != M || input1.size[1] != K)
if (input1.dims > 2 || input1.size[0] != M || (input1.dims > 1 && input1.size[1] != K) || input1.dims == 1)
{
int shape[] = {static_cast<int>(M), static_cast<int>(K)};
reshapedInput1 = input1.reshape(1, 2, shape);
@ -113,7 +113,7 @@ static Mat batchwiseMatMul(
// input2 should be of size KxN
// check if input2 needs reshape, if needs reshape
if (input2.dims > 2 || input2.size[0] != K || input2.size[1] != N)
if (input2.dims > 2 || input2.size[0] != K || (input2.dims > 1 && input2.size[1] != N) || input2.dims == 1)
{
int shape2[] = {static_cast<int>(K), static_cast<int>(N)};
reshapedInput2 = input2.reshape(1, 2, shape2);

View File

@ -1452,7 +1452,7 @@ TEST_P(Test_ONNX_layers, LSTM_layout_batch)
testONNXModels("lstm_layout_1", npy, 0.005, 0.005, false, false, 3);
}
TEST_P(Test_ONNX_layers, DISABLED_Einsum_1D)
TEST_P(Test_ONNX_layers, Einsum_1D)
{
testONNXModels("einsum_1d", npy, 0, 0, false, false, 2);
}
@ -1482,12 +1482,12 @@ TEST_P(Test_ONNX_layers, Einsum_5D)
testONNXModels("einsum_5d", npy, 0, 0, false, false, 2);
}
TEST_P(Test_ONNX_layers, DISABLED_Einsum_InnerProduct)
TEST_P(Test_ONNX_layers, Einsum_InnerProduct)
{
testONNXModels("einsum_inner", npy, 0, 0, false, false, 2);
}
TEST_P(Test_ONNX_layers, DISABLED_Einsum_HadamardProduct)
TEST_P(Test_ONNX_layers, Einsum_HadamardProduct)
{
testONNXModels("einsum_hadamard", npy, 0, 0, false, false, 2);
}