@Override
    protected TensorFunction<Reference> lazyGetFunction() {
        if (inputs.size() < 1 || inputs.get(0).function().isEmpty()) {
            return null;
        }

        IntermediateOperation data = inputs.get(0);
        OrderedTensorType dataType = data.type().get();
        String dataFunctionName = data.rankingExpressionFunctionName();

        List<com.yahoo.tensor.functions.Slice.DimensionValue<Reference>> dimensionValues = new ArrayList<>();

        for (int axis = 0; axis < dataType.rank(); ++axis) {
            int start = starts[axis];
            int step = steps[axis];

            String inputDimensionName = dataType.dimensions().get(axis).name();
            String outputDimensionName = type.dimensions().get(axis).name();

            ExpressionNode stepSize = new ConstantNode(new DoubleValue(step));
            ExpressionNode startIndex = new ConstantNode(new DoubleValue(start));

            // step * (d0 + start)
            ExpressionNode reference = new ReferenceNode(outputDimensionName);
            ExpressionNode plus = new EmbracedNode(new OperationNode(reference, Operator.plus, startIndex));
            ExpressionNode mul = new OperationNode(stepSize, Operator.multiply, plus);

            dimensionValues.add(new com.yahoo.tensor.functions.Slice.DimensionValue<>(Optional.of(inputDimensionName), wrapScalar(new EmbracedNode(mul))));
        }

        TensorFunction<Reference> inputIndices = new TensorFunctionNode.ExpressionTensorFunction(new ReferenceNode(dataFunctionName));
        com.yahoo.tensor.functions.Slice<Reference> sliceIndices = new com.yahoo.tensor.functions.Slice<>(inputIndices, dimensionValues);
        ExpressionNode sliceExpression = new TensorFunctionNode(sliceIndices);

        return Generate.bound(type.type(), wrapScalar(sliceExpression));
    }
Onnx slice operation.

Opset 1 to 9 accepts starts, ends, and axes tensors as attributes

Opset 10 and up accepts starts, ends, axes, and steps tensors as inputs. Here we assume these are
constants, otherwise we can't import this model because that would mean we
would not know the resulting tensor type until run-time, and that is currently
not supported in Vespa.
model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Slice.java