|
12 | 12 | #include "LinearWithSelu_FromONNX.hxx" |
13 | 13 | #include "input_models/references/LinearWithSelu.ref.hxx" |
14 | 14 |
|
| 15 | +#include "Sub_FromONNX.hxx" |
| 16 | +#include "input_models/references/Sub.ref.hxx" |
| 17 | + |
| 18 | +#include "Add_FromONNX.hxx" |
| 19 | +#include "input_models/references/Add.ref.hxx" |
| 20 | + |
| 21 | +#include "Mul_FromONNX.hxx" |
| 22 | +#include "input_models/references/Mul.ref.hxx" |
| 23 | + |
| 24 | +#include "Div_FromONNX.hxx" |
| 25 | +#include "input_models/references/Div.ref.hxx" |
| 26 | + |
15 | 27 | #include "LinearWithLeakyRelu_FromONNX.hxx" |
16 | 28 | #include "input_models/references/LinearWithLeakyRelu.ref.hxx" |
17 | 29 |
|
@@ -134,6 +146,110 @@ TEST(ONNX, Linear32) |
134 | 146 | } |
135 | 147 | } |
136 | 148 |
|
| 149 | +TEST(ONNX, Sub) |
| 150 | + { |
| 151 | + constexpr float TOLERANCE = DEFAULT_TOLERANCE; |
| 152 | + |
| 153 | + // Preparing the standard input |
| 154 | + std::vector<float> input1({ |
| 155 | + 1, 2 |
| 156 | + }); |
| 157 | + std::vector<float> input2({ |
| 158 | + 0, 1 |
| 159 | + }); |
| 160 | + TMVA_SOFIE_Sub::Session s("Sub_FromONNX.dat"); |
| 161 | + |
| 162 | + std::vector<float> output = s.infer(input2.data(),input1.data()); |
| 163 | + |
| 164 | + // Checking output size |
| 165 | + EXPECT_EQ(output.size(), sizeof(Sub_ExpectedOutput::outputs) / sizeof(float)); |
| 166 | + |
| 167 | + float *correct = Sub_ExpectedOutput::outputs; |
| 168 | + |
| 169 | + // Checking every output value, one by one |
| 170 | + for (size_t i = 0; i < output.size(); ++i) { |
| 171 | + EXPECT_LE(std::abs(output[i] - correct[i]), TOLERANCE); |
| 172 | + } |
| 173 | + } |
| 174 | + |
| 175 | + |
| 176 | +TEST(ONNX, Add) |
| 177 | + { |
| 178 | + constexpr float TOLERANCE = DEFAULT_TOLERANCE; |
| 179 | + |
| 180 | + // Preparing the standard input |
| 181 | + std::vector<float> input1({ |
| 182 | + 1, 2 |
| 183 | + }); |
| 184 | + std::vector<float> input2({ |
| 185 | + 0, 1 |
| 186 | + }); |
| 187 | + TMVA_SOFIE_Add::Session s("Add_FromONNX.dat"); |
| 188 | + |
| 189 | + std::vector<float> output = s.infer(input1.data(),input2.data()); |
| 190 | + |
| 191 | + // Checking output size |
| 192 | + EXPECT_EQ(output.size(), sizeof(Add_ExpectedOutput::outputs) / sizeof(float)); |
| 193 | + |
| 194 | + float *correct = Add_ExpectedOutput::outputs; |
| 195 | + |
| 196 | + // Checking every output value, one by one |
| 197 | + for (size_t i = 0; i < output.size(); ++i) { |
| 198 | + EXPECT_LE(std::abs(output[i] - correct[i]), TOLERANCE); |
| 199 | + } |
| 200 | + } |
| 201 | + |
| 202 | +TEST(ONNX, Mul) |
| 203 | + { |
| 204 | + constexpr float TOLERANCE = DEFAULT_TOLERANCE; |
| 205 | + |
| 206 | + // Preparing the standard input |
| 207 | + std::vector<float> input1({ |
| 208 | + 1, 2 |
| 209 | + }); |
| 210 | + std::vector<float> input2({ |
| 211 | + 0, 1 |
| 212 | + }); |
| 213 | + TMVA_SOFIE_Mul::Session s("Mul_FromONNX.dat"); |
| 214 | + |
| 215 | + std::vector<float> output = s.infer(input1.data(),input2.data()); |
| 216 | + |
| 217 | + // Checking output size |
| 218 | + EXPECT_EQ(output.size(), sizeof(Mul_ExpectedOutput::outputs) / sizeof(float)); |
| 219 | + |
| 220 | + float *correct = Mul_ExpectedOutput::outputs; |
| 221 | + |
| 222 | + // Checking every output value, one by one |
| 223 | + for (size_t i = 0; i < output.size(); ++i) { |
| 224 | + EXPECT_LE(std::abs(output[i] - correct[i]), TOLERANCE); |
| 225 | + } |
| 226 | + } |
| 227 | + |
| 228 | +TEST(ONNX, Div) |
| 229 | + { |
| 230 | + constexpr float TOLERANCE = DEFAULT_TOLERANCE; |
| 231 | + |
| 232 | + // Preparing the standard input |
| 233 | + std::vector<float> input1({ |
| 234 | + 4, 2 |
| 235 | + }); |
| 236 | + std::vector<float> input2({ |
| 237 | + 2, 2 |
| 238 | + }); |
| 239 | + TMVA_SOFIE_Div::Session s("Div_FromONNX.dat"); |
| 240 | + |
| 241 | + std::vector<float> output = s.infer(input2.data(),input1.data()); |
| 242 | + |
| 243 | + // Checking output size |
| 244 | + EXPECT_EQ(output.size(), sizeof(Div_ExpectedOutput::outputs) / sizeof(float)); |
| 245 | + |
| 246 | + float *correct = Div_ExpectedOutput::outputs; |
| 247 | + |
| 248 | + // Checking every output value, one by one |
| 249 | + for (size_t i = 0; i < output.size(); ++i) { |
| 250 | + EXPECT_LE(std::abs(output[i] - correct[i]), TOLERANCE); |
| 251 | + } |
| 252 | + } |
137 | 253 |
|
138 | 254 | TEST(ONNX, Linear64) |
139 | 255 | { |
|
0 commit comments