summaryrefslogtreecommitdiffstats
path: root/vespajlib
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2017-01-03 10:39:05 +0100
committerJon Bratseth <bratseth@yahoo-inc.com>2017-01-03 10:39:05 +0100
commitf711b8413e501a2835e814d1e69e9cc8636d739b (patch)
tree71b4590f2704c681a2b04df326c2a5176a6636ea /vespajlib
parent6dfd393b05800e53a0becf85ddd12614c22a77be (diff)
Use int labels for speed
Diffstat (limited to 'vespajlib')
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/functions/Concat.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/functions/Concat.java b/vespajlib/src/main/java/com/yahoo/tensor/functions/Concat.java
index 6c02cd08294..f212e66fc86 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/functions/Concat.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/functions/Concat.java
@@ -149,7 +149,8 @@ public class Concat extends PrimitiveTensorFunction {
*/
private TensorAddress combineAddresses(TensorAddress a, int[] aToIndexes, TensorAddress b, int[] bToIndexes,
TensorType concatType, int concatOffset, String concatDimension) {
- String[] joinedLabels = new String[concatType.dimensions().size()];
+ int[] joinedLabels = new int[concatType.dimensions().size()];
+ Arrays.fill(joinedLabels, -1);
int concatDimensionIndex = concatType.indexOfDimension(concatDimension).get();
mapContent(a, joinedLabels, aToIndexes, concatDimensionIndex, concatOffset); // note: This sets a nonsensical value in the concat dimension
boolean compatible = mapContent(b, joinedLabels, bToIndexes, concatDimensionIndex, concatOffset); // ... which is overwritten by the right value here
@@ -178,15 +179,15 @@ public class Concat extends PrimitiveTensorFunction {
* @return true if the mapping was successful, false if one of the destination positions was
* occupied by a different value
*/
- private boolean mapContent(TensorAddress from, String[] to, int[] indexMap, int concatDimension, int concatOffset) {
+ private boolean mapContent(TensorAddress from, int[] to, int[] indexMap, int concatDimension, int concatOffset) {
for (int i = 0; i < from.size(); i++) {
int toIndex = indexMap[i];
if (concatDimension == toIndex) {
- to[toIndex] = String.valueOf(from.intLabel(i) + concatOffset);
+ to[toIndex] = from.intLabel(i) + concatOffset;
}
else {
- if (to[toIndex] != null && !to[toIndex].equals(from.label(i))) return false;
- to[toIndex] = from.label(i);
+ if (to[toIndex] != -1 && to[toIndex] != from.intLabel(i)) return false;
+ to[toIndex] = from.intLabel(i);
}
}
return true;