(builder, node, graph, err)
convert to CoreML Gather Along Axis Layer:
    https://github.com/apple/coremltools/blob/655b3be5cc0d42c3c4fa49f0f0e4a93a26b3e492/mlmodel/format/NeuralNetwork.proto#L4296
convert to CoreML Gather Along Axis Layer:
    https://github.com/apple/coremltools/blob/655b3be5cc0d42c3c4fa49f0f0e4a93a26b3e492/mlmodel/format/NeuralNetwork.proto#L4296
convert to CoreML Gather Along Axis Layer : https : // github . com / apple / coremltools / blob / 655b3be5cc0d42c3c4fa49f0f0e4a93a26b3e492 / mlmodel / format / NeuralNetwork . proto#L4296
def _convert_gather(builder, node, graph, err):
    '''
    convert to CoreML Gather Along Axis Layer:
    https://github.com/apple/coremltools/blob/655b3be5cc0d42c3c4fa49f0f0e4a93a26b3e492/mlmodel/format/NeuralNetwork.proto#L4296
    '''
    axis = node.attrs.get('axis', 0)

    if len(node.inputs) != 2:
        err.unsupported_op_configuration(builder, node, graph, "Error in ONNX model: Gather expects two inputs")
    
    if node.inputs[0] in node.input_tensors and node.inputs[0] not in graph.constants_loaded:
        value = node.input_tensors[node.inputs[0]]
        builder.add_load_constant_nd(
            name=node.name + '_load_data',
            output_name=node.inputs[0],
            constant_value=value,
            shape=[1] if value.shape == () else value.shape
        )
        graph.constants_loaded.add(node.inputs[0])
    
    if node.inputs[1] in node.input_tensors and node.inputs[1] not in graph.constants_loaded:
        value = node.input_tensors[node.inputs[1]]
        builder.add_load_constant_nd(
            name=node.name+ '_load_indices',
            output_name=node.inputs[1],
            constant_value=value,
            shape=[1] if value.shape == () else value.shape
        )
        graph.constants_loaded.add(node.inputs[1])
    
    builder.add_gather(
        name=node.name,
        input_names=[node.inputs[0], node.inputs[1]],
        output_name=node.outputs[0],
        axis=axis
    )
def _convert_gather ( builder , node , graph , err ) : axis = node . attrs . get ( 'axis' , 0 ) if len ( node . inputs ) != 2 : err . unsupported_op_configuration ( builder , node , graph , "Error in ONNX model: Gather expects two inputs" ) if node . inputs [ 0 ] in node . input_tensors and node . inputs [ 0 ] not in graph . constants_loaded : value = node . input_tensors [ node . inputs [ 0 ] ] builder . add_load_constant_nd ( name = node . name + '_load_data' , output_name = node . inputs [ 0 ] , constant_value = value , shape = [ 1 ] if value . shape == ( ) else value . shape ) graph . constants_loaded . add ( node . inputs [ 0 ] ) if node . inputs [ 1 ] in node . input_tensors and node . inputs [ 1 ] not in graph . constants_loaded : value = node . input_tensors [ node . inputs [ 1 ] ] builder . add_load_constant_nd ( name = node . name + '_load_indices' , output_name = node . inputs [ 1 ] , constant_value = value , shape = [ 1 ] if value . shape == ( ) else value . shape ) graph . constants_loaded . add ( node . inputs [ 1 ] ) builder . add_gather ( name = node . name , input_names = [ node . inputs [ 0 ] , node . inputs [ 1 ] ] , output_name = node . outputs [ 0 ] , axis = axis )