private void encodeDimensions(GrowableByteBuffer buffer, IndexedTensor tensor) {
        buffer.putInt1_4Bytes(tensor.type().dimensions().size());
        for (int i = 0; i < tensor.type().dimensions().size(); i++) {
            buffer.putUtf8String(tensor.type().dimensions().get(i).name());
            buffer.putInt1_4Bytes((int)tensor.dimensionSizes().size(i)); // XXX: Size truncation
        }
    }
Implementation of a dense binary format for a tensor on the form:

Sorted dimensions = num_dimensions [dimension_str_len dimension_str_bytes dimension_size_int]*
Cell_values = [double, double, double, ...]*
where values are encoded in order of increasing indexes in each dimension, increasing
indexes of later dimensions in the dimension type before earlier.

@author bratseth
vespajlib/src/main/java/com/yahoo/tensor/serialization/DenseBinaryFormat.java