private Tensor castFromSomeFloat(Tensor tensor, TensorType type) {
        Tensor.Builder builder = Tensor.Builder.of(type);
        var restrict = selectRestrict(type.valueType());
        for (Iterator<Tensor.Cell> i = tensor.cellIterator(); i.hasNext(); ) {
            Tensor.Cell cell = i.next();
            builder.cell(cell.getKey(), restrict.apply(cell.getFloatValue()));
        }
        return builder.build();
    }
The <i>cell_cast</i> tensor function creates a new tensor with the specified cell value type.

@author lesters
vespajlib/src/main/java/com/yahoo/tensor/functions/CellCast.java