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

Function anyFeatureDescriptionOfModel

mlmodel/src/Utils.cpp:136–157  ·  view source on GitHub ↗

A utility function to invoke a handler with input, output, and state feature description of the model. It traverses a pipeline model. The function returns `true` if any of the feature descriptions met the specified criteria predicate function.

Source from the content-addressed store, hash-verified

134/// The function returns `true` if any of the feature descriptions met
135/// the specified criteria predicate function.
136static bool anyFeatureDescriptionOfModel(const Specification::Model &model,
137 std::function<bool(const Specification::FeatureDescription& fd)> criteria) {
138 return walkModelAndPipeline(
139 model,
140 [&criteria](const Specification::Model& m) {
141 const auto& modelDescription = m.description();
142 if (modelDescription.functions_size() == 0) {
143 // A single function syntax
144 if (anyFeatureDescriptionOfDescription(modelDescription, criteria)) {
145 return true;
146 }
147 } else {
148 // A multi function syntax
149 for (const auto& functionDescription: modelDescription.functions()) {
150 if (anyFeatureDescriptionOfDescription(modelDescription, criteria)) {
151 return true;
152 }
153 }
154 }
155 return false;
156 });
157}
158
159bool CoreML::hasCustomLayer(const Specification::Model& model) {
160 return walkModelAndPipeline(

Callers 7

hasFlexibleShapesFunction · 0.85
hasFloat16MultiArrayFunction · 0.85
hasInt8MultiArrayFunction · 0.85
hasGrayscaleFloat16ImageFunction · 0.85
hasCategoricalSequencesFunction · 0.85

Calls 3

walkModelAndPipelineFunction · 0.85
descriptionMethod · 0.80

Tested by

no test coverage detected