Thanks @fdwr for pointing out the inconsistency of starts and sizes definitions of slice op when revisiting the PR #359 (comment), where Dwayne mentioned:
I just noticed slices parameter starts still has the negative number policy and accepts axis coordinates as long rather than unsigned long; and its sizes parameter has an unusual policy that -1 is special, whereas sizes in resample2D is sequence. Do we want to rationalize these for consistency too, having higher level policy like this determined by the calling framework?
In a followed comment, Dwayne also pointed out that
we see that every other sizes parameter is unsigned long (see below), leaving only slice as sequence sizes.
From my point of view, using unsigned integer for starts and sizes makes sense. It not only would help ensure the consistency across the spec but also would simplify the implementation. The native ML APIs, such as DirectML's DML_SLICE1_OPERATOR_DESC and XNNPACK's xnn_define_static_slice, usually use unsigned integer starts/offsets and sizes.
Another simplification idea is whether the MLSliceOptions should be removed. MLSliceOptions.axes is used to indicate the dimensions of the input shape to which starts and sizes apply. However, native ML APIs, e.g. DirectML's DML_SLICE1_OPERATOR_DESC, XNNPACK's xnn_define_static_slice and MLCompute's MLCSliceLayer, usually expect the starts and offsets for all dimensions to be provided.
With that, a possible simplified slice op definition would be
partial interface MLGraphBuilder {
// The length of `starts` and `sizes` sequences should equal to the rank of input tensor.
MLOperand slice(MLOperand input, sequence<unsigned long> starts, sequence<unsigned long> sizes);
};
Thoughts?
Thanks @fdwr for pointing out the inconsistency of
startsandsizesdefinitions ofsliceop when revisiting the PR #359 (comment), where Dwayne mentioned:In a followed comment, Dwayne also pointed out that
From my point of view, using unsigned integer for
startsandsizesmakes sense. It not only would help ensure the consistency across the spec but also would simplify the implementation. The native ML APIs, such as DirectML'sDML_SLICE1_OPERATOR_DESCand XNNPACK'sxnn_define_static_slice, usually use unsigned integer starts/offsets and sizes.Another simplification idea is whether the
MLSliceOptionsshould be removed.MLSliceOptions.axesis used to indicate the dimensions of the input shape to which starts and sizes apply. However, native ML APIs, e.g. DirectML'sDML_SLICE1_OPERATOR_DESC, XNNPACK'sxnn_define_static_sliceand MLCompute'sMLCSliceLayer, usually expect thestartsandoffsetsfor all dimensions to be provided.With that, a possible simplified
sliceop definition would beThoughts?