| 296 | } |
| 297 | |
| 298 | void PadInt8Test(tflite::BuiltinOperator padOperatorCode = tflite::BuiltinOperator_PAD, |
| 299 | int8_t paddingValue = 0, |
| 300 | int8_t p = 3, |
| 301 | float quantizationScale = -2.0f, |
| 302 | int32_t quantizationOffset = 3) |
| 303 | { |
| 304 | // Set input data |
| 305 | std::vector<int32_t> inputShape { 2, 2, 2 }; |
| 306 | std::vector<int32_t> outputShape { 3, 5, 6 }; |
| 307 | std::vector<int32_t> paddingShape { 3, 2 }; |
| 308 | |
| 309 | std::vector<int8_t> inputValues = { 0, 4, |
| 310 | 2, -5, |
| 311 | 6, 1, |
| 312 | 5, -2 }; |
| 313 | |
| 314 | std::vector<int8_t> expectedOutputValues = { p, p, p, p, p, p, |
| 315 | p, p, p, p, p, p, |
| 316 | p, p, 0, 4, p, p, |
| 317 | p, p, 2, -5, p, p, |
| 318 | p, p, p, p, p, p, |
| 319 | |
| 320 | p, p, p, p, p, p, |
| 321 | p, p, p, p, p, p, |
| 322 | p, p, 6, 1, p, p, |
| 323 | p, p, 5, -2, p, p, |
| 324 | p, p, p, p, p, p, |
| 325 | |
| 326 | p, p, p, p, p, p, |
| 327 | p, p, p, p, p, p, |
| 328 | p, p, p, p, p, p, |
| 329 | p, p, p, p, p, p, |
| 330 | p, p, p, p, p, p }; |
| 331 | |
| 332 | std::vector<int32_t> paddingDim = { 0, 1, 2, 1, 2, 2 }; |
| 333 | |
| 334 | PadTest<int8_t>(padOperatorCode, |
| 335 | ::tflite::TensorType_INT8, |
| 336 | inputShape, |
| 337 | paddingShape, |
| 338 | outputShape, |
| 339 | inputValues, |
| 340 | paddingDim, |
| 341 | expectedOutputValues, |
| 342 | paddingValue, |
| 343 | {}, |
| 344 | quantizationScale, |
| 345 | quantizationOffset); |
| 346 | } |
| 347 | |
| 348 | void PadUint8Test(tflite::BuiltinOperator padOperatorCode = tflite::BuiltinOperator_PAD, |
| 349 | uint8_t paddingValue = 0, |