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

Function testEmptyInputModel_downgradeToIOS18

mlmodel/tests/UtilsTests.cpp:142–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142int testEmptyInputModel_downgradeToIOS18() {
143 // This model doesn't have input. Such empty input models are supported in iOS18 and later.
144 auto spec = Specification::Model();
145 spec.set_specificationversion(MLMODEL_SPECIFICATION_VERSION_NEWEST);
146 auto* modelDescription = spec.mutable_description();
147
148 auto output = modelDescription->add_output();
149 output->set_name("output");
150 output->mutable_type()->mutable_multiarraytype()->set_datatype(Specification::ArrayFeatureType_ArrayDataType::ArrayFeatureType_ArrayDataType_FLOAT32);
151 output->mutable_type()->mutable_multiarraytype()->add_shape(1);
152
153 auto* net = spec.mutable_neuralnetwork();
154 auto* layer = net->add_layers();
155 layer->set_name("load_constantND_layer");
156 layer->add_output("output");
157 layer->mutable_loadconstantnd()->add_shape(1);
158 layer->mutable_loadconstantnd()->mutable_data()->add_floatvalue(0.1f);
159
160 // The model uses empty input, which was introduced in iOS18.
161 Model emptyInputModel(spec);
162 ML_ASSERT_EQ(emptyInputModel.getProto().specificationversion(), MLMODEL_SPECIFICATION_VERSION_IOS18);
163
164 // Now, add an input.
165 auto input = modelDescription->add_input();
166 input->set_name("input");
167 input->mutable_type()->mutable_multiarraytype()->set_datatype(Specification::ArrayFeatureType_ArrayDataType::ArrayFeatureType_ArrayDataType_FLOAT32);
168 input->mutable_type()->mutable_multiarraytype()->add_shape(1);
169
170 // The model uses EXACT_ARRAY_MAPPING, which was introduced in iOS13. Other than that,
171 // there is nothing special. We expect the downgrade utility sets it to iOS13.
172 Model modelWithInput(spec);
173 ML_ASSERT_EQ(modelWithInput.getProto().specificationversion(), MLMODEL_SPECIFICATION_VERSION_IOS13);
174
175 return 0;
176}
177
178int testMultiFunctionModel_downgradeToIOS18() {
179 // This model doesn't have input. Such empty input models are supported in iOS18 and later.

Callers

nothing calls this directly

Calls 3

ModelClass · 0.50
set_nameMethod · 0.45
mutable_dataMethod · 0.45

Tested by

no test coverage detected