(builder, node, graph, err)
convert to CoreML Padding / ConstantPadding Layer:
    https://github.com/apple/coremltools/blob/655b3be5cc0d42c3c4fa49f0f0e4a93a26b3e492/mlmodel/format/NeuralNetwork.proto#L4397
    https://github.com/apple/coremltools/blob/655b3be5cc0d42c3c4fa49f0f0e4a93a26b3e492/mlmodel/format/NeuralNetwork.proto#L1822
convert to CoreML Padding / ConstantPadding Layer:
    https://github.com/apple/coremltools/blob/655b3be5cc0d42c3c4fa49f0f0e4a93a26b3e492/mlmodel/format/NeuralNetwork.proto#L4397
    https://github.com/apple/coremltools/blob/655b3be5cc0d42c3c4fa49f0f0e4a93a26b3e492/mlmodel/format/NeuralNetwork.proto#L1822
convert to CoreML Padding / ConstantPadding Layer : https : // github . com / apple / coremltools / blob / 655b3be5cc0d42c3c4fa49f0f0e4a93a26b3e492 / mlmodel / format / NeuralNetwork . proto#L4397 https : // github . com / apple / coremltools / blob / 655b3be5cc0d42c3c4fa49f0f0e4a93a26b3e492 / mlmodel / format / NeuralNetwork . proto#L1822
def _convert_pad(builder, node, graph, err):
    '''
    convert to CoreML Padding / ConstantPadding Layer:
    https://github.com/apple/coremltools/blob/655b3be5cc0d42c3c4fa49f0f0e4a93a26b3e492/mlmodel/format/NeuralNetwork.proto#L4397
    https://github.com/apple/coremltools/blob/655b3be5cc0d42c3c4fa49f0f0e4a93a26b3e492/mlmodel/format/NeuralNetwork.proto#L1822
    '''
    mode = node.attrs.get('mode', 'constant')

    try:
        mode = mode.decode()
    except (UnicodeDecodeError, AttributeError):
        pass

    if mode == 'constant':    
        pads = node.attrs.get('pads', [])
        value = node.attrs.get('value', 0.0)

        builder.add_constant_pad(
            name=node.name,
            input_names=node.inputs,
            output_name=node.outputs[0],
            value=value,
            pad_to_given_output_size_mode=False,
            pad_amounts=pads
        )
    else:
        _convert_pad_5d(builder, node, graph, err)
def _convert_pad ( builder , node , graph , err ) : mode = node . attrs . get ( 'mode' , 'constant' ) try : mode = mode . decode ( ) except ( UnicodeDecodeError , AttributeError ) : pass if mode == 'constant' : pads = node . attrs . get ( 'pads' , [ ] ) value = node . attrs . get ( 'value' , 0.0 ) builder . add_constant_pad ( name = node . name , input_names = node . inputs , output_name = node . outputs [ 0 ] , value = value , pad_to_given_output_size_mode = False , pad_amounts = pads ) else : _convert_pad_5d ( builder , node , graph , err )