use of com.yahoo.tensor.Tensor in project vespa by vespa-engine.
the class TensorField method decode.
@Override
public Tensor decode(ByteBuffer buffer) {
int length = buffer.getInt();
if (length == 0)
return null;
ByteBuffer contentBuffer = ByteBuffer.wrap(buffer.array(), buffer.arrayOffset() + buffer.position(), length);
Tensor tensor = TypedBinaryFormat.decode(Optional.empty(), new GrowableByteBuffer(contentBuffer));
buffer.position(buffer.position() + length);
return tensor;
}
use of com.yahoo.tensor.Tensor in project vespa by vespa-engine.
the class TensorField method decode.
@Override
public Tensor decode(ByteBuffer b, FastHit hit) {
Tensor tensor = decode(b);
hit.setField(name, tensor);
return tensor;
}
use of com.yahoo.tensor.Tensor in project vespa by vespa-engine.
the class ConcatTestCase method testUnequalEqualSizesDifferentDimensionOneUnbound.
@Test
public void testUnequalEqualSizesDifferentDimensionOneUnbound() {
Tensor a = Tensor.from("tensor(x[]):{ {x:0}:1, {x:1}:2 }");
Tensor b = Tensor.from("tensor(y[3]):{ {y:0}:4, {y:1}:5, {y:2}:6 }");
assertConcat("tensor(x[],y[3])", "tensor(x[3],y[3]):{{x:0,y:0}:1.0,{x:0,y:1}:1.0,{x:0,y:2}:1.0,{x:1,y:0}:2.0,{x:1,y:1}:2.0,{x:1,y:2}:2.0,{x:2,y:0}:4.0,{x:2,y:1}:5.0,{x:2,y:2}:6.0}", a, b, "x");
assertConcat("tensor(x[],y[4])", "tensor(x[2],y[4]):{{x:0,y:0}:1.0,{x:0,y:1}:4.0,{x:0,y:2}:5.0,{x:0,y:3}:6.0,{x:1,y:0}:2.0,{x:1,y:1}:4.0,{x:1,y:2}:5.0,{x:1,y:3}:6.0}", a, b, "y");
assertConcat("tensor(x[],y[3],z[2])", "tensor(x[2],y[3],z[2]):{{x:0,y:0,z:0}:1.0,{x:0,y:0,z:1}:4.0,{x:0,y:1,z:0}:1.0,{x:0,y:1,z:1}:5.0,{x:0,y:2,z:0}:1.0,{x:0,y:2,z:1}:6.0,{x:1,y:0,z:0}:2.0,{x:1,y:0,z:1}:4.0,{x:1,y:1,z:0}:2.0,{x:1,y:1,z:1}:5.0,{x:1,y:2,z:0}:2.0,{x:1,y:2,z:1}:6.0}", a, b, "z");
}
use of com.yahoo.tensor.Tensor in project vespa by vespa-engine.
the class ConcatTestCase method testConcatNumberAndVector.
@Test
public void testConcatNumberAndVector() {
Tensor a = Tensor.from("{1}");
Tensor b = Tensor.from("tensor(x[3]):{ {x:0}:2, {x:1}:3, {x:2}:4 }");
assertConcat("tensor(x[4]):{ {x:0}:1, {x:1}:2, {x:2}:3, {x:3}:4 }", a, b, "x");
assertConcat("tensor(x[3],y[2]):{ {x:0,y:0}:1, {x:1,y:0}:1, {x:2,y:0}:1, " + "{x:0,y:1}:2, {x:1,y:1}:3, {x:2,y:1}:4 }", a, b, "y");
}
use of com.yahoo.tensor.Tensor in project vespa by vespa-engine.
the class ConcatTestCase method testConcatEqualShapes.
@Test
public void testConcatEqualShapes() {
Tensor a = Tensor.from("tensor(x[3]):{ {x:0}:1, {x:1}:2, {x:2}:3 }");
Tensor b = Tensor.from("tensor(x[3]):{ {x:0}:4, {x:1}:5, {x:2}:6 }");
assertConcat("tensor(x[6]):{ {x:0}:1, {x:1}:2, {x:2}:3, {x:3}:4, {x:4}:5, {x:5}:6 }", a, b, "x");
assertConcat("tensor(x[3],y[2]):{ {x:0,y:0}:1, {x:1,y:0}:2, {x:2,y:0}:3, " + "{x:0,y:1}:4, {x:1,y:1}:5, {x:2,y:1}:6 }", a, b, "y");
}
Aggregations