| 337 | } |
| 338 | |
| 339 | int testSamePaddingConvolution() { |
| 340 | |
| 341 | Specification::Model m1; |
| 342 | |
| 343 | auto *topIn = m1.mutable_description()->add_input(); |
| 344 | topIn->set_name("input"); |
| 345 | auto *shape = topIn->mutable_type()->mutable_multiarraytype(); |
| 346 | auto *shape1 = shape->mutable_shaperange()->add_sizeranges(); |
| 347 | shape1->set_lowerbound(4); |
| 348 | shape1->set_upperbound(4); |
| 349 | auto *shape2 = shape->mutable_shaperange()->add_sizeranges(); |
| 350 | shape2->set_lowerbound(100); |
| 351 | shape2->set_upperbound(100); |
| 352 | auto *shape3 = shape->mutable_shaperange()->add_sizeranges(); |
| 353 | shape3->set_lowerbound(100); |
| 354 | shape3->set_upperbound(200); |
| 355 | |
| 356 | auto *out = m1.mutable_description()->add_output(); |
| 357 | out->set_name("output"); |
| 358 | out->mutable_type()->mutable_multiarraytype(); |
| 359 | |
| 360 | auto *nn = m1.mutable_neuralnetwork(); |
| 361 | |
| 362 | Specification::NeuralNetworkLayer *convLayer = nn->add_layers(); |
| 363 | convLayer->add_input("input"); |
| 364 | convLayer->add_output("output"); |
| 365 | Specification::ConvolutionLayerParams *convParams = convLayer->mutable_convolution(); |
| 366 | convParams->set_outputchannels(5); |
| 367 | convParams->set_kernelchannels(4); |
| 368 | convParams->add_kernelsize(7); |
| 369 | convParams->add_kernelsize(8); |
| 370 | convParams->mutable_same(); |
| 371 | convParams->set_hasbias(false); |
| 372 | for (int i = 0; i < 5*4*7*8; i++) { |
| 373 | convParams->mutable_weights()->add_floatvalue(1.0); |
| 374 | } |
| 375 | |
| 376 | NeuralNetworkShaper shapes(m1); |
| 377 | |
| 378 | const ShapeConstraint &inShape = shapes.shape("input"); |
| 379 | ML_ASSERT(inShape.sequenceRange().minimumValue() == 0); |
| 380 | ML_ASSERT(inShape.sequenceRange().maximumValue().isUnbound()); |
| 381 | |
| 382 | ML_ASSERT(inShape.batchRange().minimumValue() == 0); |
| 383 | ML_ASSERT(inShape.batchRange().maximumValue().isUnbound()); |
| 384 | |
| 385 | ML_ASSERT(inShape.channelRange().minimumValue() == 4); |
| 386 | ML_ASSERT(inShape.channelRange().maximumValue().value() == 4); |
| 387 | |
| 388 | ML_ASSERT(inShape.heightRange().minimumValue() == 100); |
| 389 | ML_ASSERT(inShape.heightRange().maximumValue().value() == 100); |
| 390 | |
| 391 | ML_ASSERT(inShape.widthRange().minimumValue() == 100); |
| 392 | ML_ASSERT(inShape.widthRange().maximumValue().value() == 200); |
| 393 | |
| 394 | const ShapeConstraint &outShape = shapes.shape("output"); |
| 395 | ML_ASSERT(outShape.sequenceRange().minimumValue() == 0); |
| 396 | ML_ASSERT(outShape.sequenceRange().maximumValue().isUnbound()); |
nothing calls this directly
no test coverage detected