MCPcopy Create free account
hub / github.com/apple/coremltools / testValidCrop2

Function testValidCrop2

mlmodel/tests/NNValidatorTests.cpp:3698–3746  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3696}
3697
3698int testValidCrop2() {
3699
3700 Specification::Model m1;
3701
3702 auto *topIn = m1.mutable_description()->add_input();
3703 topIn->set_name("input");
3704 auto *shape = topIn->mutable_type()->mutable_multiarraytype();
3705 shape->add_shape(1);
3706 shape->add_shape(234);
3707 shape->add_shape(332);
3708
3709 auto *topIn2 = m1.mutable_description()->add_input();
3710 topIn2->set_name("input2");
3711 auto* shape2 = topIn2->mutable_type()->mutable_multiarraytype();
3712 shape2->add_shape(2);
3713 shape2->add_shape(10);
3714 shape2->add_shape(11);
3715
3716 auto *out3 = m1.mutable_description()->add_output();
3717 out3->set_name("probs");
3718 out3->mutable_type()->mutable_multiarraytype();
3719
3720 const auto nn = m1.mutable_neuralnetwork();
3721
3722 Specification::NeuralNetworkLayer *cropLayer = nn->add_layers();
3723 cropLayer->add_input("input");
3724 cropLayer->add_input("input2");
3725 cropLayer->add_output("probs");
3726 auto *params = cropLayer->mutable_crop();
3727 params->add_offset(1);
3728 params->add_offset(2);
3729
3730 Result res = validate<MLModelType_neuralNetwork>(m1);
3731 ML_ASSERT_GOOD(res);
3732
3733 NeuralNetworkShaper shaper(m1);
3734 ML_ASSERT(shaper.isValid());
3735
3736 ML_ASSERT(shaper.shape("probs").channelRange().minimum().value() == 1);
3737 ML_ASSERT(shaper.shape("probs").channelRange().maximum().value() == 1);
3738
3739 ML_ASSERT(shaper.shape("probs").heightRange().minimum().value() == 10);
3740 ML_ASSERT(shaper.shape("probs").heightRange().maximum().value() == 10);
3741
3742 ML_ASSERT(shaper.shape("probs").widthRange().minimum().value() == 11);
3743 ML_ASSERT(shaper.shape("probs").widthRange().maximum().value() == 11);
3744
3745 return 0;
3746}
3747
3748int testInvalidCrop2() {
3749

Callers

nothing calls this directly

Calls 6

minimumMethod · 0.80
maximumMethod · 0.80
set_nameMethod · 0.45
isValidMethod · 0.45
valueMethod · 0.45
shapeMethod · 0.45

Tested by

no test coverage detected