use of com.yahoo.tensor.Tensor 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.Tensor in project vespa by vespa-engine.
the class MixedBinaryFormatTestCase method assertSerialization.
private void assertSerialization(Tensor tensor, TensorType expectedType) {
byte[] encodedTensor = TypedBinaryFormat.encode(tensor);
Tensor decodedTensor = TypedBinaryFormat.decode(Optional.of(expectedType), GrowableByteBuffer.wrap(encodedTensor));
assertEquals(tensor, decodedTensor);
}
use of com.yahoo.tensor.Tensor 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.Tensor 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);
}
use of com.yahoo.tensor.Tensor in project vespa by vespa-engine.
the class VariableTensor method evaluate.
@Override
public <NAMETYPE extends TypeContext.Name> Tensor evaluate(EvaluationContext<NAMETYPE> context) {
Tensor tensor = context.getTensor(name);
if (tensor == null)
return null;
verifyType(tensor.type());
return tensor;
}
Aggregations