| 140 | } |
| 141 | |
| 142 | int 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 | |
| 178 | int testMultiFunctionModel_downgradeToIOS18() { |
| 179 | // This model doesn't have input. Such empty input models are supported in iOS18 and later. |
nothing calls this directly
no test coverage detected