parameters: (builder, node, graph, err)
docstring: convert to CoreML Slice Static Layer:
      https://github.com/apple/coremltools/blob/655b3be5cc0d42c3c4fa49f0f0e4a93a26b3e492/mlmodel/format/NeuralNetwork.proto#L5082
docstring_summary: convert to CoreML Slice Static Layer:
      https://github.com/apple/coremltools/blob/655b3be5cc0d42c3c4fa49f0f0e4a93a26b3e492/mlmodel/format/NeuralNetwork.proto#L5082
docstring_tokens: convert to CoreML Slice Static Layer : https : // github . com / apple / coremltools / blob / 655b3be5cc0d42c3c4fa49f0f0e4a93a26b3e492 / mlmodel / format / NeuralNetwork . proto#L5082
function: def _convert_slice_ir4v9(builder, node, graph, err):
      """
      convert to CoreML Slice Static Layer:
      https://github.com/apple/coremltools/blob/655b3be5cc0d42c3c4fa49f0f0e4a93a26b3e492/mlmodel/format/NeuralNetwork.proto#L5082
      """
      if node.inputs[0] in graph.shape_dict:
          data_shape = graph.shape_dict[node.inputs[0]]
      else:
          rank = builder._get_rank(node.inputs[0])
          if rank == -1:
              return err.unsupported_op_configuration(
                  builder, node, graph, "Input shape not available"
              )
          data_shape = [INT_MAX] * rank
  
      len_of_data = len(data_shape)
      begin_masks = [True] * len_of_data
      end_masks = [True] * len_of_data
  
      default_axes = list(range(len_of_data))
      default_steps = [1] * len_of_data
  
      ip_starts = node.attrs.get("starts")
      ip_ends = node.attrs.get("ends")
      axes = node.attrs.get("axes", default_axes)
      steps = node.attrs.get("steps", default_steps)
  
      starts = [0] * len_of_data
      ends = [0] * len_of_data
  
      for i in range(len(axes)):
          current_axes = axes[i]
          starts[current_axes] = ip_starts[i]
          ends[current_axes] = ip_ends[i]
          # n <= end <= INT_MAX implies end is -1, hence end_mask should be True
          # otherwise end_mask should be False
          if ends[current_axes] < data_shape[current_axes]:
              # this means end is not -1
              end_masks[current_axes] = False
  
          if starts[current_axes] != 0:
              begin_masks[current_axes] = False
  
      builder.add_slice_static(
          name=node.name,
          input_name=node.inputs[0],
          output_name=node.outputs[0],
          begin_ids=starts,
          end_ids=ends,
          strides=steps,
          begin_masks=begin_masks,
          end_masks=end_masks,
      )
function_tokens: def _convert_slice_ir4v9 ( builder , node , graph , err ) : if node . inputs [ 0 ] in graph . shape_dict : data_shape = graph . shape_dict [ node . inputs [ 0 ] ] else : rank = builder . _get_rank ( node . inputs [ 0 ] ) if rank == - 1 : return err . unsupported_op_configuration ( builder , node , graph , "Input shape not available" ) data_shape = [ INT_MAX ] * rank len_of_data = len ( data_shape ) begin_masks = [ True ] * len_of_data end_masks = [ True ] * len_of_data default_axes = list ( range ( len_of_data ) ) default_steps = [ 1 ] * len_of_data ip_starts = node . attrs . get ( "starts" ) ip_ends = node . attrs . get ( "ends" ) axes = node . attrs . get ( "axes" , default_axes ) steps = node . attrs . get ( "steps" , default_steps ) starts = [ 0 ] * len_of_data ends = [ 0 ] * len_of_data for i in range ( len ( axes ) ) : current_axes = axes [ i ] starts [ current_axes ] = ip_starts [ i ] ends [ current_axes ] = ip_ends [ i ] # n <= end <= INT_MAX implies end is -1, hence end_mask should be True # otherwise end_mask should be False if ends [ current_axes ] < data_shape [ current_axes ] : # this means end is not -1 end_masks [ current_axes ] = False if starts [ current_axes ] != 0 : begin_masks [ current_axes ] = False builder . add_slice_static ( name = node . name , input_name = node . inputs [ 0 ] , output_name = node . outputs [ 0 ] , begin_ids = starts , end_ids = ends , strides = steps , begin_masks = begin_masks , end_masks = end_masks , )