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

Function validateOptionalNN

mlmodel/src/Validation/InterfaceValidators.cpp:691–708  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

689 }
690
691 inline Result validateOptionalNN(const Specification::ModelDescription& description) {
692 // just need to check that not all inputs are optional
693 bool hasNotOptional = false;
694 for (const auto& input : description.input()) {
695 if (input.type().Type_case() == Specification::FeatureType::kStateType) { // ignore optionality for State type input (which is always non-optional)
696 hasNotOptional = true;
697 continue;
698 }
699 if (!input.type().isoptional()) {
700 hasNotOptional = true;
701 break;
702 }
703 }
704 if (description.input().size() > 0 && !hasNotOptional) {
705 return Result(ResultType::INVALID_MODEL_PARAMETERS, "At least one feature for a neural network must NOT be optional.");
706 }
707 return Result();
708 }
709
710 Result validateOptional(const Specification::Model& format) {
711 Result r;

Callers 1

validateOptionalFunction · 0.85

Calls 3

ResultClass · 0.85
sizeMethod · 0.65
typeMethod · 0.45

Tested by

no test coverage detected