| 887 | } |
| 888 | |
| 889 | static bool hasIOS13NeuralNetworkFeatures(const Specification::Model& model) { |
| 890 | |
| 891 | /* check if any of the messages in NeuralNetwork.proto, that were added in iOS version 13, are being used. |
| 892 | If they are, return True, otherwise return False. |
| 893 | |
| 894 | In particular, check for the presence of the following messages: |
| 895 | 1. any new layer type, which was not in iOS 12. |
| 896 | 2. if the value of enums "NeuralNetworkMultiArrayShapeMapping" or "NeuralNetworkImageShapeMapping" is non 0 |
| 897 | */ |
| 898 | return walkModelAndPipeline( |
| 899 | model, |
| 900 | [](const Specification::Model& m) { |
| 901 | if (m.Type_case() == Specification::Model::TypeCase::kNeuralNetwork) { |
| 902 | if (m.neuralnetwork().arrayinputshapemapping() != Specification::NeuralNetworkMultiArrayShapeMapping::RANK5_ARRAY_MAPPING) { |
| 903 | return true; |
| 904 | } |
| 905 | if (m.neuralnetwork().imageinputshapemapping() != Specification::NeuralNetworkImageShapeMapping::RANK5_IMAGE_MAPPING) { |
| 906 | return true; |
| 907 | } |
| 908 | } else if (m.Type_case() == Specification::Model::TypeCase::kNeuralNetworkRegressor) { |
| 909 | if (m.neuralnetworkregressor().arrayinputshapemapping() != Specification::NeuralNetworkMultiArrayShapeMapping::RANK5_ARRAY_MAPPING) { |
| 910 | return true; |
| 911 | } |
| 912 | if (m.neuralnetworkregressor().imageinputshapemapping() != Specification::NeuralNetworkImageShapeMapping::RANK5_IMAGE_MAPPING) { |
| 913 | return true; |
| 914 | } |
| 915 | } else if (m.Type_case() == Specification::Model::TypeCase::kNeuralNetworkClassifier) { |
| 916 | if (m.neuralnetworkclassifier().arrayinputshapemapping() != Specification::NeuralNetworkMultiArrayShapeMapping::RANK5_ARRAY_MAPPING) { |
| 917 | return true; |
| 918 | } |
| 919 | if (m.neuralnetworkclassifier().imageinputshapemapping() != Specification::NeuralNetworkImageShapeMapping::RANK5_IMAGE_MAPPING) { |
| 920 | return true; |
| 921 | } |
| 922 | } |
| 923 | |
| 924 | // check for new layers: by checking if its NOT one of the layers supported in iOS 12 |
| 925 | if (const auto *layers = getNNSpec(m)) { |
| 926 | for (const auto& layer: *layers) { |
| 927 | if (!isIOS12NeuralNetworkLayer(layer)) { |
| 928 | return true; |
| 929 | } |
| 930 | } |
| 931 | } |
| 932 | return false; |
| 933 | }); |
| 934 | } |
| 935 | |
| 936 | static bool hasIOS14NeuralNetworkFeatures(const Specification::Model& model) { |
| 937 |
no test coverage detected