Layer specification for Model Cropping#

To crop a model, the user needs to specify the points at which the model needs to be cropped. The cropping points specify the desired input(s)/output(s) for the cropped model. The convention for specifying inputs/outputs differs slightly depending on the model’s framework-

  1. For Keras models
    1. Input layer selection

      To select a layer to be the input layer of the cropped model, specify the name of the layer.

    2. Output layer selection

      To select a layer to be the output layer of the cropped model, specify the name of the layer

  2. For TensorFlow/TensorFlow Lite/ONNX models
    1. Input layer selection

      To select a layer to be the input layer of the cropped model, specify the name of its input layer.

    2. Output layer selection

      To select a layer to be the output layer of the cropped model, specify the name of its output layer

While selecting input layers for the second case, if multiple layers share the same input layer name, the NeuralCompiler will raise a ValueError asking the user to specify the index of the intended layer. The list of available choices will be displayed to make it easier to determine the index of the intended layer. An example is shown below:

ValueError: Specified input: 'Preprocessor/sub' is a multi-output layer. Specify an output index to select the intended layer - 'Preprocessor/sub:1' selects the 2nd output of 'Preprocessor/sub'
Available outputs: ['Shape', 'FirstStageFeatureExtractor/Shape', 'FirstStageFeatureExtractor/Shape_1', 'FirstStageFeatureExtractor/resnet_v1_101/resnet_v1_101/Pad']