Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tmva/sofie/inc/TMVA/ROperator_Conv.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ public:
out << SP << SP << "}\n";
out << SP << "}\n";

// Dilation is already folded into the expanded kernel shape and the dilated tensor_<X>_f
// layout above, so the dense im2col below must use dilation 1 to avoid double-counting it.
fAttrDilations = std::vector<size_t>(3, 1);

//out << SP << "char " << OpName << "_transA = 'T';\n";
out << SP << "char " << OpName << "_transA = 'N';\n";
out << SP << "char " << OpName << "_transB = 'N';\n";
Expand Down
22 changes: 22 additions & 0 deletions tmva/sofie/test/TestCustomModelsFromONNX.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ constexpr auto modelDataSuffix = "_FromONNX.dat";
#include "input_models/references/Erf.ref.hxx"
#include "input_models/references/LinearWithSigmoid.ref.hxx"
#include "input_models/references/ConvWithPadding.ref.hxx"
#include "input_models/references/ConvWithDilation.ref.hxx"
#include "input_models/references/ConvWithoutPadding.ref.hxx"
#include "input_models/references/ConvWithAutopadSameLower.ref.hxx"
#include "input_models/references/ConvWithAutopadSameUpper.ref.hxx"
Expand Down Expand Up @@ -726,6 +727,27 @@ TEST(ONNX, ConvWithStridesPadding)
}


TEST(ONNX, ConvWithDilation)
{
constexpr float TOLERANCE = DEFAULT_TOLERANCE;

// Preparing the standard all-ones input
std::vector<float> input(49);
std::iota(input.begin(), input.end(), 0.0f);
ASSERT_INCLUDE_AND_RUN(std::vector<float>, "ConvWithDilation", input);

// Checking output size
EXPECT_EQ(output.size(), std::size(ConvWithDilation_ExpectedOutput::all_ones));

float *correct = ConvWithDilation_ExpectedOutput::all_ones;

// Checking every output value, one by one
for (size_t i = 0; i < output.size(); ++i) {
EXPECT_LE(std::abs(output[i] - correct[i]), TOLERANCE);
}
}


TEST(ONNX, ConvWithStridesNoPadding)
{
constexpr float TOLERANCE = DEFAULT_TOLERANCE;
Expand Down
Binary file added tmva/sofie/test/input_models/ConvWithDilation.onnx
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace ConvWithDilation_ExpectedOutput {
float all_ones[] = {98.400002f, 102.900009f, 107.400002f, 129.899994f, 134.399994f, 138.899994f, 161.399994f, 165.899994f, 170.399994f};
} // namespace ConvWithDilation_ExpectedOutput
Loading