shubhamvishu commented on code in PR #16631:
URL: https://github.com/apache/lucene/pull/16631#discussion_r3961527388
##########
lucene/core/src/java25/org/apache/lucene/internal/vectorization/PanamaVectorUtilSupport.java:
##########
@@ -584,6 +588,24 @@ private static int int4DotProductBody(ByteVectorLoader a,
ByteVectorLoader b, in
return sum;
}
+ @Override
+ public void int4Unpack(byte[] packed, byte[] unpacked) {
+ final int len = packed.length;
+ final int bound = BYTE_SPECIES_FULL.loopBound(len);
+ int i = 0;
+ for (; i < bound; i += BYTE_SPECIES_FULL.length()) {
+ ByteVector v = ByteVector.fromArray(BYTE_SPECIES_FULL, packed, i);
+ // LSHR is a logical shift within the byte lane, so the high nibble
needs no mask.
+ v.lanewise(LSHR, 4).intoArray(unpacked, i);
+ v.lanewise(VectorOperators.AND, (byte) 0x0F).intoArray(unpacked, len +
i);
+ }
+ // scalar tail
+ for (; i < len; i++) {
+ unpacked[i] = (byte) ((packed[i] >> 4) & 0x0F);
+ unpacked[len + i] = (byte) (packed[i] & 0x0F);
+ }
Review Comment:
Minor : I understand this has been an convention in this file though I think
we could "possibly" further optimize for the case where vector length isn't
divisible by `BYTE_SPECIES_FULL.length` (eg : 300 dim and
`BYTE_SPECIES_FULL.length` as 32 like Graviton 3) and the remaining tail is >
16 or > 8; provided simd over that smaller tail/chunk is faster than simple
iteration over it.
At the same time, how often are there such non power of 2 dimensions used in
real scenario? maybe not often?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]