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();
}
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);
}
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);
}
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);
}
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);
}
Aggregations