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

Function testUpsampleArgsortSpec

mlmodel/tests/NNValidatorTests.cpp:3185–3234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3183}
3184
3185int testUpsampleArgsortSpec() {
3186 /* Ensure that the model is treated as the iOS 14 specification
3187 when new layers are included and upsample only includes
3188 legacy params.
3189 */
3190 Specification::Model m;
3191
3192 auto *in = m.mutable_description()->add_input();
3193 in->set_name("input");
3194 auto *inShape = in->mutable_type()->mutable_multiarraytype();
3195 inShape->add_shape(1);
3196 inShape->add_shape(3);
3197 inShape->add_shape(3);
3198
3199 auto *out = m.mutable_description()->add_output();
3200 out->set_name("output");
3201 auto *outShape = out->mutable_type()->mutable_multiarraytype();
3202 outShape->add_shape(1);
3203 outShape->add_shape(3);
3204 outShape->add_shape(3);
3205
3206 const auto nn = m.mutable_neuralnetwork();
3207 nn->set_arrayinputshapemapping(Specification::NeuralNetworkMultiArrayShapeMapping::EXACT_ARRAY_MAPPING);
3208
3209 auto *upsampleLayer = nn->add_layers();
3210 upsampleLayer->set_name("upsample");
3211 upsampleLayer->add_input("input");
3212 upsampleLayer->add_output("A");
3213 auto *upsampleParams = upsampleLayer->mutable_upsample();
3214
3215 // Scaling factor needs to be 2D
3216 upsampleParams->add_scalingfactor(1.0);
3217 upsampleParams->add_scalingfactor(1.0);
3218
3219 upsampleParams->set_mode(Specification::UpsampleLayerParams_InterpolationMode_BILINEAR);
3220
3221 auto *argsortLayer = nn->add_layers();
3222 argsortLayer->set_name("argsort");
3223 argsortLayer->add_input("A");
3224 argsortLayer->add_output("output");
3225 auto *argsortParams = argsortLayer->mutable_argsort();
3226 argsortParams->set_axis(1);
3227
3228 Result res = validate<MLModelType_neuralNetwork>(m);
3229 ML_ASSERT_GOOD(res);
3230 Model mlmodel = Model(m);
3231 ML_ASSERT(mlmodel.getProto().specificationversion() == MLMODEL_SPECIFICATION_VERSION_IOS14);
3232
3233 return 0;
3234}
3235
3236int testValidSoftmax() {
3237

Callers

nothing calls this directly

Calls 2

ModelClass · 0.50
set_nameMethod · 0.45

Tested by

no test coverage detected