Search in sources :

Example 31 with TensorType

use of com.yahoo.tensor.TensorType in project vespa by vespa-engine.

the class SerializationTestCase method buildTensor.

private Tensor buildTensor(JsonNode tensor) {
    TensorType type = tensorType(tensor);
    Tensor.Builder builder = Tensor.Builder.of(type);
    tensorCells(tensor, builder);
    return builder.build();
}
Also used : Tensor(com.yahoo.tensor.Tensor) TensorType(com.yahoo.tensor.TensorType)

Example 32 with TensorType

use of com.yahoo.tensor.TensorType in project vespa by vespa-engine.

the class ConcatTestCase method assertConcat.

private void assertConcat(String expectedType, String expected, Tensor a, Tensor b, String dimension) {
    Tensor expectedAsTensor = Tensor.from(expected);
    TensorType inferredType = new Concat(new ConstantTensor(a), new ConstantTensor(b), dimension).type(new MapEvaluationContext());
    Tensor result = a.concat(b, dimension);
    if (expectedType != null)
        assertEquals(TensorType.fromSpec(expectedType), inferredType);
    else
        assertEquals(expectedAsTensor.type(), inferredType);
    assertEquals(expectedAsTensor, result);
}
Also used : Tensor(com.yahoo.tensor.Tensor) TensorType(com.yahoo.tensor.TensorType) MapEvaluationContext(com.yahoo.tensor.evaluation.MapEvaluationContext)

Example 33 with TensorType

use of com.yahoo.tensor.TensorType in project vespa by vespa-engine.

the class MixedBinaryFormatTestCase method testOneMappedSerialization.

@Test
public void testOneMappedSerialization() {
    TensorType type = new TensorType.Builder().mapped("x").build();
    Tensor tensor = MixedTensor.Builder.of(type).cell().label("x", "0").value(1).cell().label("x", "1").value(2).build();
    assertSerialization(tensor);
}
Also used : MixedTensor(com.yahoo.tensor.MixedTensor) Tensor(com.yahoo.tensor.Tensor) TensorType(com.yahoo.tensor.TensorType) Test(org.junit.Test)

Example 34 with TensorType

use of com.yahoo.tensor.TensorType in project vespa by vespa-engine.

the class MixedBinaryFormatTestCase method testTwoIndexedSerialization.

@Test
public void testTwoIndexedSerialization() {
    TensorType type = new TensorType.Builder().indexed("x").indexed("y", 3).build();
    Tensor tensor = MixedTensor.Builder.of(type).cell().label("x", 0).label("y", 0).value(1).cell().label("x", 0).label("y", 1).value(2).cell().label("x", 1).label("y", 0).value(4).cell().label("x", 1).label("y", 1).value(5).cell().label("x", 1).label("y", 2).value(6).build();
    assertSerialization(tensor);
}
Also used : MixedTensor(com.yahoo.tensor.MixedTensor) Tensor(com.yahoo.tensor.Tensor) TensorType(com.yahoo.tensor.TensorType) Test(org.junit.Test)

Example 35 with TensorType

use of com.yahoo.tensor.TensorType in project vespa by vespa-engine.

the class MixedBinaryFormatTestCase method testOneIndexedSerialization.

@Test
public void testOneIndexedSerialization() {
    TensorType type = new TensorType.Builder().indexed("y", 3).build();
    Tensor tensor = MixedTensor.Builder.of(type).cell().label("y", 0).value(1).cell().label("y", 1).value(2).build();
    assertSerialization(tensor);
}
Also used : MixedTensor(com.yahoo.tensor.MixedTensor) Tensor(com.yahoo.tensor.Tensor) TensorType(com.yahoo.tensor.TensorType) Test(org.junit.Test)

Aggregations

TensorType (com.yahoo.tensor.TensorType)38 Tensor (com.yahoo.tensor.Tensor)18 ExpressionNode (com.yahoo.searchlib.rankingexpression.rule.ExpressionNode)8 IndexedTensor (com.yahoo.tensor.IndexedTensor)7 MixedTensor (com.yahoo.tensor.MixedTensor)6 TensorAddress (com.yahoo.tensor.TensorAddress)6 Test (org.junit.Test)6 DoubleValue (com.yahoo.searchlib.rankingexpression.evaluation.DoubleValue)4 OrderedTensorType (com.yahoo.searchlib.rankingexpression.integration.tensorflow.importer.OrderedTensorType)4 ConstantNode (com.yahoo.searchlib.rankingexpression.rule.ConstantNode)4 GeneratorLambdaFunctionNode (com.yahoo.searchlib.rankingexpression.rule.GeneratorLambdaFunctionNode)4 Generate (com.yahoo.tensor.functions.Generate)4 List (java.util.List)4 ImmutableList (com.google.common.collect.ImmutableList)3 RankProfile (com.yahoo.searchdefinition.RankProfile)3 RankingExpression (com.yahoo.searchlib.rankingexpression.RankingExpression)3 DimensionSizes (com.yahoo.tensor.DimensionSizes)3 Reduce (com.yahoo.tensor.functions.Reduce)3 TensorFunction (com.yahoo.tensor.functions.TensorFunction)3 ArrayList (java.util.ArrayList)3