[ONNX]Add Slice_v10 frontend impl, am I right?


#1

Hi,
I added my own onnx frontend ‘slice’ v10 version, can anyone help to check it?

@classmethod
def _impl_v10(cls, inputs, attr, params):

    #prepare attr
    attr['starts'] = params[inputs[1].name_hint].asnumpy()
    attr['ends'] = params[inputs[2].name_hint].asnumpy()
    attr['axes'] = params[inputs[3].name_hint].asnumpy()
    attr['strides'] = params[inputs[4].name_hint].asnumpy()
    try:
        # Update the starts and ends according to axes if required.
        if (max(attr['axes']) + 1) != len(attr['axes']):
            new_axes = []
            new_starts = []
            new_ends = []
            pop_index = 0
            for i in range(max(attr['axes']) + 1):
                if i in attr['axes']:
                    new_axes.append(i)
                    new_starts.append(attr['starts'][pop_index])
                    new_ends.append(attr['ends'][pop_index])
                    pop_index += 1
                else:
                    new_axes.append(i)
                    new_starts.append(0)
                    new_ends.append(np.iinfo(np.int32).max)
            attr['axes'] = new_axes
            attr['starts'] = new_starts
            attr['ends'] = new_ends
    except KeyError:
        pass

    return AttrCvt('strided_slice',
                   transforms={'starts': 'begin',
                               'ends': 'end',},
                   ignores=['axes'])([inputs[0]], attr)
'