| 3139 | } |
| 3140 | |
| 3141 | int testValidUpsampleAlignCorners() { |
| 3142 | |
| 3143 | Specification::Model m1; |
| 3144 | |
| 3145 | auto *topIn = m1.mutable_description()->add_input(); |
| 3146 | topIn->set_name("input"); |
| 3147 | auto *shape = topIn->mutable_type()->mutable_multiarraytype(); |
| 3148 | shape->add_shape(5); |
| 3149 | shape->add_shape(5); |
| 3150 | shape->add_shape(5); |
| 3151 | |
| 3152 | auto *out3 = m1.mutable_description()->add_output(); |
| 3153 | out3->set_name("probs"); |
| 3154 | out3->mutable_type()->mutable_multiarraytype(); |
| 3155 | |
| 3156 | const auto nn = m1.mutable_neuralnetwork(); |
| 3157 | nn->set_arrayinputshapemapping(Specification::NeuralNetworkMultiArrayShapeMapping::EXACT_ARRAY_MAPPING); |
| 3158 | |
| 3159 | Specification::NeuralNetworkLayer *upsampleLayer = nn->add_layers(); |
| 3160 | upsampleLayer->add_input("input"); |
| 3161 | upsampleLayer->add_output("probs"); |
| 3162 | auto *params = upsampleLayer->mutable_upsample(); |
| 3163 | |
| 3164 | // Scaling factor needs to be 2D |
| 3165 | params->add_scalingfactor(1.0); |
| 3166 | params->add_scalingfactor(1.0); |
| 3167 | |
| 3168 | params->set_mode(Specification::UpsampleLayerParams_InterpolationMode_BILINEAR); |
| 3169 | params->set_linearupsamplemode(Specification::UpsampleLayerParams_LinearUpsampleMode_ALIGN_CORNERS_FALSE); |
| 3170 | |
| 3171 | Result res = validate<MLModelType_neuralNetwork>(m1); |
| 3172 | ML_ASSERT_GOOD(res); |
| 3173 | |
| 3174 | params->set_linearupsamplemode(Specification::UpsampleLayerParams_LinearUpsampleMode_ALIGN_CORNERS_TRUE); |
| 3175 | |
| 3176 | res = validate<MLModelType_neuralNetwork>(m1); |
| 3177 | ML_ASSERT_GOOD(res); |
| 3178 | |
| 3179 | // Check that the new field sets spec version to ios 14 |
| 3180 | Model mlmodel = Model(m1); |
| 3181 | ML_ASSERT(mlmodel.getProto().specificationversion() == MLMODEL_SPECIFICATION_VERSION_IOS14); |
| 3182 | return 0; |
| 3183 | } |
| 3184 | |
| 3185 | int testUpsampleArgsortSpec() { |
| 3186 | /* Ensure that the model is treated as the iOS 14 specification |