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

Function walkModelAndPipeline

mlmodel/src/Utils.cpp:65–96  ·  view source on GitHub ↗

A utility function to traverse a pipeline model and invoke a handler. If the model is not a pipeline, it simply invokes the handler with the model. If the model is a pipeline, it invokes the handler with each sub model first, and then with the pipeline model. The traversal stops if the handler returns `true`.

Source from the content-addressed store, hash-verified

63///
64/// The traversal stops if the handler returns `true`.
65static bool walkModelAndPipeline(const Specification::Model &model,
66 std::function<bool(const Specification::Model& m)> handler) {
67 switch (model.Type_case()) {
68 case Specification::Model::kPipeline:
69 for (auto &m : model.pipeline().models()) {
70 if (walkModelAndPipeline(m, handler)) {
71 return true;
72 }
73 }
74 break;
75 case Specification::Model::kPipelineRegressor:
76 for (auto &m : model.pipelineregressor().pipeline().models()) {
77 if (walkModelAndPipeline(m, handler)) {
78 return true;
79 }
80 }
81 break;
82 case Specification::Model::kPipelineClassifier:
83 for (auto &m : model.pipelineclassifier().pipeline().models()) {
84 if (walkModelAndPipeline(m, handler)) {
85 return true;
86 }
87 }
88 break;
89 default:
90 break;
91 }
92 if (handler(model)) {
93 return true;
94 }
95 return false;
96}
97
98/// A utility function to invoke a handler with input, output, and
99/// state feature description.

Callers 15

hasCustomLayerMethod · 0.85
hasWeightOfTypeFunction · 0.85
hasOpsetsFunction · 0.85
hasIOS11_2FeaturesMethod · 0.85
hasIOS12FeaturesMethod · 0.85
hasIOS13FeaturesMethod · 0.85
hasIOS14FeaturesMethod · 0.85
hasIOS15FeaturesMethod · 0.85
hasIOS16FeaturesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected