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

Function hasFlexibleShapes

mlmodel/src/Utils.cpp:388–401  ·  view source on GitHub ↗

We'll check if the model has ONLY the IOS12 shape specifications if the old ones are also filled in with something plausible, then there is nothing preventing us from running on older versions of Core ML.

Source from the content-addressed store, hash-verified

386// if the old ones are also filled in with something plausible, then there is nothing
387// preventing us from running on older versions of Core ML.
388static bool hasFlexibleShapes(const Specification::Model& model) {
389 return anyFeatureDescriptionOfModel(
390 model,
391 [](const auto& fd) {
392 if (fd.type().Type_case() == Specification::FeatureType::kMultiArrayType &&
393 fd.type().multiarraytype().ShapeFlexibility_case() != Specification::ArrayFeatureType::SHAPEFLEXIBILITY_NOT_SET) {
394 return true;
395 } else if (fd.type().Type_case() == Specification::FeatureType::kImageType &&
396 fd.type().imagetype().SizeFlexibility_case() != Specification::ImageFeatureType::SIZEFLEXIBILITY_NOT_SET) {
397 return true;
398 }
399 return false;
400 });
401}
402
403static bool hasFloat16MultiArray(const Specification::Model& model) {
404 return anyFeatureDescriptionOfModel(

Callers 1

hasIOS12FeaturesMethod · 0.85

Calls 2

typeMethod · 0.45

Tested by

no test coverage detected