diff options
author | Arne Juul <arnej@yahooinc.com> | 2023-11-10 10:02:02 +0000 |
---|---|---|
committer | Arne Juul <arnej@yahooinc.com> | 2023-11-10 10:14:23 +0000 |
commit | 1ec05cfed625e6395b8d3346c4f15b5bc7507dcf (patch) | |
tree | cbe16302842983afd9192b78a745532e419cd04a /searchlib/src/main | |
parent | 27c62ead49c88382f128034c48e22d77a83f8104 (diff) |
unpack_bits_from_int8 -> unpack_bits
Diffstat (limited to 'searchlib/src/main')
-rw-r--r-- | searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/UnpackBitsNode.java (renamed from searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/UnpackBitsFromInt8.java) | 11 | ||||
-rwxr-xr-x | searchlib/src/main/javacc/RankingExpressionParser.jj | 10 |
2 files changed, 12 insertions, 9 deletions
diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/UnpackBitsFromInt8.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/UnpackBitsNode.java index 84203da4a7e..467a7860053 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/UnpackBitsFromInt8.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/UnpackBitsNode.java @@ -24,9 +24,9 @@ import java.util.Objects; * @author arnej */ @Beta -public class UnpackBitsFromInt8 extends CompositeNode { +public class UnpackBitsNode extends CompositeNode { - private static String operationName = "unpack_bits_from_int8"; + private static String operationName = "unpack_bits"; private enum EndianNess { BIG_ENDIAN("big"), LITTLE_ENDIAN("little"); @@ -47,7 +47,7 @@ public class UnpackBitsFromInt8 extends CompositeNode { final TensorType.Value targetCellType; final EndianNess endian; - public UnpackBitsFromInt8(ExpressionNode input, TensorType.Value targetCellType, String endianNess) { + public UnpackBitsNode(ExpressionNode input, TensorType.Value targetCellType, String endianNess) { this.input = input; this.targetCellType = targetCellType; this.endian = EndianNess.fromId(endianNess); @@ -141,6 +141,9 @@ public class UnpackBitsFromInt8 extends CompositeNode { } private Meta analyze(TensorType inputType) { + if (inputType.valueType() != TensorType.Value.INT8) { + throw new IllegalArgumentException("bad " + operationName + "; input must have cell-type int8, but it was: " + inputType.valueType()); + } TensorType inputDenseType = inputType.indexedSubtype(); if (inputDenseType.rank() == 0) { throw new IllegalArgumentException("bad " + operationName + "; input must have indexed dimension, but type was: " + inputType); @@ -174,7 +177,7 @@ public class UnpackBitsFromInt8 extends CompositeNode { public CompositeNode setChildren(List<ExpressionNode> newChildren) { if (newChildren.size() != 1) throw new IllegalArgumentException("Expected 1 child but got " + newChildren.size()); - return new UnpackBitsFromInt8(newChildren.get(0), targetCellType, endian.toString()); + return new UnpackBitsNode(newChildren.get(0), targetCellType, endian.toString()); } @Override diff --git a/searchlib/src/main/javacc/RankingExpressionParser.jj b/searchlib/src/main/javacc/RankingExpressionParser.jj index 1da8a5ece89..42f8f846199 100755 --- a/searchlib/src/main/javacc/RankingExpressionParser.jj +++ b/searchlib/src/main/javacc/RankingExpressionParser.jj @@ -129,7 +129,7 @@ TOKEN : <MAP: "map"> | <MAP_SUBSPACES: "map_subspaces"> | - <UNPACK_BITS_FROM_INT8: "unpack_bits_from_int8"> | + <UNPACK_BITS: "unpack_bits"> | <REDUCE: "reduce"> | <JOIN: "join"> | <MERGE: "merge"> | @@ -676,23 +676,23 @@ ExpressionNode tensorMacro() : } { ( - tensorExpression = tensorUnpackBitsFromInt8() + tensorExpression = tensorUnpackBits() ) { return tensorExpression; } } -ExpressionNode tensorUnpackBitsFromInt8() : +ExpressionNode tensorUnpackBits() : { ExpressionNode tensor; String targetCellType = "float"; String endianNess = "big"; } { - <UNPACK_BITS_FROM_INT8> <LBRACE> tensor = expression() ( + <UNPACK_BITS> <LBRACE> tensor = expression() ( <COMMA> targetCellType = identifier() ( <COMMA> endianNess = identifier() )? )? <RBRACE> { - return new UnpackBitsFromInt8(tensor, TensorType.Value.fromId(targetCellType), endianNess); + return new UnpackBitsNode(tensor, TensorType.Value.fromId(targetCellType), endianNess); } } |