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

Method validateGeneric

mlmodel/src/Model.cpp:65–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63 }
64
65 Result Model::validateGeneric(const Specification::Model& model) {
66 // make sure compat version fields are filled in
67 if (model.specificationversion() == 0) {
68 return Result(ResultType::INVALID_COMPATIBILITY_VERSION,
69 "Model specification version field missing or corrupt.");
70 }
71
72 // check public compatibility version
73 // note: this one should always be backward compatible, so use > here
74 if (model.specificationversion() > MLMODEL_SPECIFICATION_VERSION) {
75 std::stringstream msg;
76 msg << "The model supplied is of version "
77 << model.specificationversion()
78 << ", intended for a newer version of Xcode. This version of Xcode supports model version "
79 << MLMODEL_SPECIFICATION_VERSION
80 << " or earlier.";
81 return Result(ResultType::UNSUPPORTED_COMPATIBILITY_VERSION,
82 msg.str());
83 }
84
85 // validate model interface
86 auto validationPolicy = ValidationPolicy(static_cast<MLModelType>(model.Type_case()));
87 Result r = validateModelDescription(model.description(), model.specificationversion(), validationPolicy);
88 if (!r.good()) {
89 return r;
90 }
91
92 if (model.isupdatable()){
93 if (model.specificationversion() < MLMODEL_SPECIFICATION_VERSION_IOS13) {
94 std::string err = "Model specification version for an updatable model must be '" + std::to_string(MLMODEL_SPECIFICATION_VERSION_IOS13) + "' or above.";
95 return Result(ResultType::INVALID_COMPATIBILITY_VERSION, err);
96 }
97 r = validateCanModelBeUpdatable(model);
98 }
99 if (!r.good()) {
100 return r;
101 }
102
103 return validateOptional(model);
104 }
105
106#define VALIDATE_MODEL_TYPE(TYPE) \
107 case MLModelType_ ## TYPE: \

Callers

nothing calls this directly

Calls 9

ResultClass · 0.85
ValidationPolicyClass · 0.85
validateModelDescriptionFunction · 0.85
to_stringFunction · 0.85
validateOptionalFunction · 0.85
descriptionMethod · 0.80
goodMethod · 0.80
strMethod · 0.45

Tested by

no test coverage detected