(graph, onnx_coreml_input_shape_map, disable_coreml_rank5_mapping=False)
return features
If "disable_coreml_rank5_mapping" is False, then:

    ONNX shapes to CoreML static shapes mapping
    length==1: [C]
    length==2: [B,C]
    length==3: [C,H,W] or [Seq,B,C]
    length==4: [B,C,H,W]

    If "disable_coreml_rank5_mapping" is True, then
    onnx shapes are mapped "as is" to CoreML.
If "disable_coreml_rank5_mapping" is False, then:
If disable_coreml_rank5_mapping is False then :
def _make_coreml_input_features(graph, onnx_coreml_input_shape_map, disable_coreml_rank5_mapping=False): # type: (...) -> Sequence[Tuple[Text, datatypes.Array]]
    '''
    If "disable_coreml_rank5_mapping" is False, then:

    ONNX shapes to CoreML static shapes mapping
    length==1: [C]
    length==2: [B,C]
    length==3: [C,H,W] or [Seq,B,C]
    length==4: [B,C,H,W]

    If "disable_coreml_rank5_mapping" is True, then
    onnx shapes are mapped "as is" to CoreML.
    '''
    inputs = graph.inputs
    op_types = graph.blob_to_op_type
    features = []
    for input_ in inputs:
        shape = input_[2]
        if disable_coreml_rank5_mapping:
            if len(shape) > 5:
                raise ValueError('ONNX input %s has a rank greater than 5, which is not supported in CoreML framework' % str(input_[0]))
            else:
                features.append((str(input_[0]), datatypes.Array(*shape)))
            continue

        if USE_SHAPE_MAPPING and input_[0] in onnx_coreml_input_shape_map:
            mapp = onnx_coreml_input_shape_map[input_[0]]
            if len(mapp) != len(shape):
                raise ValueError('Incorrect value in onnx_coreml_input_shape_map argument')
            graph.onnx_coreml_shape_mapping[input_[0]] = mapp
            coreml_shape = [1,1,1]
            for i in range(3):
                if (i+2) in mapp:
                    coreml_shape[i] = shape[mapp.index(i+2)]
            shape = coreml_shape
        else:
            if len(shape) == 0:
                shape = [1, 1, 1]
            elif len(shape) == 1:
                # assume [C]
                if USE_SHAPE_MAPPING:
                    graph.onnx_coreml_shape_mapping[input_[0]] = [2]
            elif len(shape) == 2:
                # assume [Batch,C]
                shape = [shape[1]]
                if USE_SHAPE_MAPPING:
                    graph.onnx_coreml_shape_mapping[input_[0]] = [1,2]
            elif len(shape) == 3:
                # assume [C,H,W] unless its connected an op that bestows another mapping
                if input_[0] in op_types and len(op_types[input_[0]]) == 1:
                    if str(op_types[input_[0]][0]) in _SEQUENCE_LAYERS_REGISTRY:
                        # (Seq,B,C)
                        shape = [shape[2]]
                        if USE_SHAPE_MAPPING:
                            graph.onnx_coreml_shape_mapping[input_[0]] = [0, 1, 2]
                    elif str(op_types[input_[0]][0]) in ['MaxPool','AveragePool','BatchNormalization',
                                                         'GlobalAveragePool','GlobalLpPool','GlobalMaxPool',
                                                         'InstanceNormalization','LRN','LpPool','Conv','ConvTranspose']:
                        # (B,C,W)
                        shape = [shape[1],1,shape[2]]
                        if USE_SHAPE_MAPPING:
                            graph.onnx_coreml_shape_mapping[input_[0]] = [1, 2, 4]
                    else:
                        if USE_SHAPE_MAPPING:
                            graph.onnx_coreml_shape_mapping[input_[0]] = [2, 3, 4]
                else:
                    if USE_SHAPE_MAPPING:
                        graph.onnx_coreml_shape_mapping[input_[0]] = [2, 3, 4]
            elif len(shape) == 4:  # (B,C,H,W) --> (C,H,W)
                shape = shape[1:]
                if USE_SHAPE_MAPPING:
                    graph.onnx_coreml_shape_mapping[input_[0]] = [1,2,3,4]
            else:
                raise ValueError("CoreML input cannot be more than rank 4. Input shape: %s, input: '%s' " % (str(shape), str(input_[0])))
        features.append((str(input_[0]), datatypes.Array(*shape)))
    return features
def _make_coreml_input_features ( graph , onnx_coreml_input_shape_map , disable_coreml_rank5_mapping = False ) : # type: (...) -> Sequence[Tuple[Text, datatypes.Array]] inputs = graph . inputs op_types = graph . blob_to_op_type features = [ ] for input_ in inputs : shape = input_ [ 2 ] if disable_coreml_rank5_mapping : if len ( shape ) > 5 : raise ValueError ( 'ONNX input %s has a rank greater than 5, which is not supported in CoreML framework' % str ( input_ [ 0 ] ) ) else : features . append ( ( str ( input_ [ 0 ] ) , datatypes . Array ( * shape ) ) ) continue if USE_SHAPE_MAPPING and input_ [ 0 ] in onnx_coreml_input_shape_map : mapp = onnx_coreml_input_shape_map [ input_ [ 0 ] ] if len ( mapp ) != len ( shape ) : raise ValueError ( 'Incorrect value in onnx_coreml_input_shape_map argument' ) graph . onnx_coreml_shape_mapping [ input_ [ 0 ] ] = mapp coreml_shape = [ 1 , 1 , 1 ] for i in range ( 3 ) : if ( i + 2 ) in mapp : coreml_shape [ i ] = shape [ mapp . index ( i + 2 ) ] shape = coreml_shape else : if len ( shape ) == 0 : shape = [ 1 , 1 , 1 ] elif len ( shape ) == 1 : # assume [C] if USE_SHAPE_MAPPING : graph . onnx_coreml_shape_mapping [ input_ [ 0 ] ] = [ 2 ] elif len ( shape ) == 2 : # assume [Batch,C] shape = [ shape [ 1 ] ] if USE_SHAPE_MAPPING : graph . onnx_coreml_shape_mapping [ input_ [ 0 ] ] = [ 1 , 2 ] elif len ( shape ) == 3 : # assume [C,H,W] unless its connected an op that bestows another mapping if input_ [ 0 ] in op_types and len ( op_types [ input_ [ 0 ] ] ) == 1 : if str ( op_types [ input_ [ 0 ] ] [ 0 ] ) in _SEQUENCE_LAYERS_REGISTRY : # (Seq,B,C) shape = [ shape [ 2 ] ] if USE_SHAPE_MAPPING : graph . onnx_coreml_shape_mapping [ input_ [ 0 ] ] = [ 0 , 1 , 2 ] elif str ( op_types [ input_ [ 0 ] ] [ 0 ] ) in [ 'MaxPool' , 'AveragePool' , 'BatchNormalization' , 'GlobalAveragePool' , 'GlobalLpPool' , 'GlobalMaxPool' , 'InstanceNormalization' , 'LRN' , 'LpPool' , 'Conv' , 'ConvTranspose' ] : # (B,C,W) shape = [ shape [ 1 ] , 1 , shape [ 2 ] ] if USE_SHAPE_MAPPING : graph . onnx_coreml_shape_mapping [ input_ [ 0 ] ] = [ 1 , 2 , 4 ] else : if USE_SHAPE_MAPPING : graph . onnx_coreml_shape_mapping [ input_ [ 0 ] ] = [ 2 , 3 , 4 ] else : if USE_SHAPE_MAPPING : graph . onnx_coreml_shape_mapping [ input_ [ 0 ] ] = [ 2 , 3 , 4 ] elif len ( shape ) == 4 : # (B,C,H,W) --> (C,H,W) shape = shape [ 1 : ] if USE_SHAPE_MAPPING : graph . onnx_coreml_shape_mapping [ input_ [ 0 ] ] = [ 1 , 2 , 3 , 4 ] else : raise ValueError ( "CoreML input cannot be more than rank 4. Input shape: %s, input: '%s' " % ( str ( shape ) , str ( input_ [ 0 ] ) ) ) features . append ( ( str ( input_ [ 0 ] ) , datatypes . Array ( * shape ) ) ) return features