| 934 | } |
| 935 | |
| 936 | static bool hasIOS14NeuralNetworkFeatures(const Specification::Model& model) { |
| 937 | |
| 938 | // Return True if the model has the new Neural network features added in |
| 939 | // ios 14 |
| 940 | return walkModelAndPipeline( |
| 941 | model, |
| 942 | [](const Specification::Model& m) { |
| 943 | if (hasDefaultValueForOptionalInputs(m)) { |
| 944 | return true; |
| 945 | } |
| 946 | |
| 947 | const auto *layers = getNNSpec(m); |
| 948 | if (!layers) { |
| 949 | return false; |
| 950 | } |
| 951 | |
| 952 | for (const auto& layer: *layers) { |
| 953 | switch (layer.layer_case()) { |
| 954 | case Specification::NeuralNetworkLayer::kCumSum: |
| 955 | case Specification::NeuralNetworkLayer::kOneHot: |
| 956 | case Specification::NeuralNetworkLayer::kClampedReLU: |
| 957 | case Specification::NeuralNetworkLayer::kArgSort: |
| 958 | case Specification::NeuralNetworkLayer::kPooling3D: |
| 959 | case Specification::NeuralNetworkLayer::kGlobalPooling3D: |
| 960 | case Specification::NeuralNetworkLayer::kSliceBySize: |
| 961 | case Specification::NeuralNetworkLayer::kConvolution3D: |
| 962 | return true; |
| 963 | case Specification::NeuralNetworkLayer::kSliceDynamic: |
| 964 | if (layer.input().size() == 7) { |
| 965 | return true; |
| 966 | } else if (layer.slicedynamic().squeezemasks_size()) { |
| 967 | return true; |
| 968 | } |
| 969 | case Specification::NeuralNetworkLayer::kUpsample: |
| 970 | if (layer.upsample().linearupsamplemode() != Specification::UpsampleLayerParams_LinearUpsampleMode_DEFAULT) { |
| 971 | return true; |
| 972 | } |
| 973 | if (layer.upsample().fractionalscalingfactor_size() > 0) { |
| 974 | return true; |
| 975 | } |
| 976 | case Specification::NeuralNetworkLayer::kReorganizeData: |
| 977 | if (layer.reorganizedata().mode() == Specification::ReorganizeDataLayerParams::PIXEL_SHUFFLE) { |
| 978 | return true; |
| 979 | } |
| 980 | case Specification::NeuralNetworkLayer::kInnerProduct: |
| 981 | if (layer.innerproduct().int8dynamicquantize()) { |
| 982 | return true; |
| 983 | } |
| 984 | case Specification::NeuralNetworkLayer::kBatchedMatmul: |
| 985 | if (layer.batchedmatmul().int8dynamicquantize()) { |
| 986 | return true; |
| 987 | } |
| 988 | case Specification::NeuralNetworkLayer::kConcatND: |
| 989 | if (layer.concatnd().interleave()) { |
| 990 | return true; |
| 991 | } |
| 992 | default: |
| 993 | continue; |
no test coverage detected