private static ByteString createRawInputContent(
            GrpcService.ModelMetadataResponse.TensorMetadata onnxInputType, IndexedTensor vespaTensor) {
        ByteBuffer buffer;
        String dataType = onnxInputType.getDatatype();
        int size = (int) vespaTensor.size();

        switch (dataType) {
            case "FP32" -> {
                buffer = ByteBuffer.allocate(size * 4).order(ByteOrder.LITTLE_ENDIAN);
                var floatBuffer = buffer.asFloatBuffer();
                for (int i = 0; i < size; i++) {
                    floatBuffer.put(vespaTensor.getFloat(i));
                }
            }
            case "FP64" -> {
                buffer = ByteBuffer.allocate(size * 8).order(ByteOrder.LITTLE_ENDIAN);
                var doubleBuffer = buffer.asDoubleBuffer();
                for (int i = 0; i < size; i++) {
                    doubleBuffer.put(vespaTensor.get(i));
                }
            }
            case "INT8" -> {
                buffer = ByteBuffer.allocate(size).order(ByteOrder.LITTLE_ENDIAN);
                for (int i = 0; i < size; i++) {
                    buffer.put((byte) vespaTensor.get(i));
                }
            }
            case "INT16" -> {
                buffer = ByteBuffer.allocate(size * 2).order(ByteOrder.LITTLE_ENDIAN);
                var shortBuffer = buffer.asShortBuffer();
                for (int i = 0; i < size; i++) {
                    shortBuffer.put((short) vespaTensor.get(i));
                }
            }
            case "INT32" -> {
                buffer = ByteBuffer.allocate(size * 4).order(ByteOrder.LITTLE_ENDIAN);
                var intBuffer = buffer.asIntBuffer();
                for (int i = 0; i < size; i++) {
                    intBuffer.put((int) vespaTensor.get(i));
                }
            }
            case "INT64" -> {
                buffer = ByteBuffer.allocate(size * 8).order(ByteOrder.LITTLE_ENDIAN);
                var longBuffer = buffer.asLongBuffer();
                for (int i = 0; i < size; i++) {
                    longBuffer.put((long) vespaTensor.get(i));
                }
            }
            case "BF16" -> {
                buffer = ByteBuffer.allocate(size * 2).order(ByteOrder.LITTLE_ENDIAN);
                var shortBuffer = buffer.asShortBuffer();
                for (int i = 0; i < size; i++) {
                    shortBuffer.put(Fp16Conversions.floatToBf16(vespaTensor.getFloat(i)));
                }
            }
            case "FP16" -> {
                buffer = ByteBuffer.allocate(size * 2).order(ByteOrder.LITTLE_ENDIAN);
                var shortBuffer = buffer.asShortBuffer();
                for (int i = 0; i < size; i++) {
                    shortBuffer.put(Fp16Conversions.floatToFp16(vespaTensor.getFloat(i)));
                }
            }
            default -> throw new TritonException("Unsupported tensor datatype from Triton: " + dataType);
        }
        return ByteString.copyFrom(buffer.rewind());
    }
Experimental model inference using Nvidia Triton as ONNX backend.

@author bjorncs
model-integration/src/main/java/ai/vespa/triton/TritonOnnxClient.java