From 35d59981840614bf4b877714ee88e273816c46d2 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Tue, 19 Dec 2017 23:02:04 +0100 Subject: Use longs for dimensions lengths in all API's This is to be able to support tensor dimensions with more than 2B elements in the future without API change. --- .../integration/tensorflow/TensorConverter.java | 2 +- .../rankingexpression/rule/GeneratorLambdaFunctionNode.java | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'searchlib/src/main/java') diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/tensorflow/TensorConverter.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/tensorflow/TensorConverter.java index df43225c333..1960cf94591 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/tensorflow/TensorConverter.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/tensorflow/TensorConverter.java @@ -26,7 +26,7 @@ public class TensorConverter { int dimensionIndex = 0; for (long dimensionSize : shape) { if (dimensionSize == 0) dimensionSize = 1; // TensorFlow ... - b.indexed("d" + (dimensionIndex++), (int) dimensionSize); + b.indexed("d" + (dimensionIndex++), dimensionSize); } return b.build(); } diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/GeneratorLambdaFunctionNode.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/GeneratorLambdaFunctionNode.java index d366c9bfbe5..9da1ba40144 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/GeneratorLambdaFunctionNode.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/GeneratorLambdaFunctionNode.java @@ -1,7 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchlib.rankingexpression.rule; -import com.google.common.collect.ImmutableList; import com.yahoo.searchlib.rankingexpression.evaluation.Context; import com.yahoo.searchlib.rankingexpression.evaluation.MapContext; import com.yahoo.searchlib.rankingexpression.evaluation.Value; @@ -10,7 +9,6 @@ import com.yahoo.tensor.TensorType; import java.util.Collections; import java.util.Deque; import java.util.List; -import java.util.function.*; /** * A tensor generating function, whose arguments are determined by a tensor type @@ -57,14 +55,14 @@ public class GeneratorLambdaFunctionNode extends CompositeNode { /** * Returns this as an operator which converts a list of integers into a double */ - public IntegerListToDoubleLambda asIntegerListToDoubleOperator() { - return new IntegerListToDoubleLambda(); + public LongListToDoubleLambda asLongListToDoubleOperator() { + return new LongListToDoubleLambda(); } - private class IntegerListToDoubleLambda implements java.util.function.Function, Double> { + private class LongListToDoubleLambda implements java.util.function.Function, Double> { @Override - public Double apply(List arguments) { + public Double apply(List arguments) { MapContext context = new MapContext(); for (int i = 0; i < type.dimensions().size(); i++) context.put(type.dimensions().get(i).name(), arguments.get(i)); -- cgit v1.2.3