diff options
author | Arne Juul <arnej@verizonmedia.com> | 2021-04-09 06:45:16 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2021-04-09 10:31:36 +0000 |
commit | 527eada361b1000fc28cca04a7234845c2df839c (patch) | |
tree | c125891e20484af3e6ed4a4585760b9b481f104a /vespajlib/src/test | |
parent | cc6d1c271efffd4a3321478884fb82c7e6141091 (diff) |
restrict values to fit into target cell type
Diffstat (limited to 'vespajlib/src/test')
-rw-r--r-- | vespajlib/src/test/java/com/yahoo/tensor/functions/CellCastTestCase.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/vespajlib/src/test/java/com/yahoo/tensor/functions/CellCastTestCase.java b/vespajlib/src/test/java/com/yahoo/tensor/functions/CellCastTestCase.java index bc10ecc3abd..c2957df4ac1 100644 --- a/vespajlib/src/test/java/com/yahoo/tensor/functions/CellCastTestCase.java +++ b/vespajlib/src/test/java/com/yahoo/tensor/functions/CellCastTestCase.java @@ -33,6 +33,17 @@ public class CellCastTestCase { assertEquals(TensorType.Value.DOUBLE, tensor.cellCast(TensorType.Value.DOUBLE).type().valueType()); assertEquals(TensorType.Value.FLOAT, tensor.cellCast(TensorType.Value.FLOAT).type().valueType()); assertEquals(tensor, tensor.cellCast(TensorType.Value.DOUBLE)); + + tensor = Tensor.from("tensor<double>(x{}):{{x:0}:2.25,{x:1}:1.00000000001,{x:2}:256.0,{x:3}:1.00390625}"); + var asFloat = Tensor.from("tensor<float>(x{}):{{x:0}:2.25,{x:1}:1.0,{x:2}:256.0,{x:3}:1.00390625}"); + var asBFloat16 = Tensor.from("tensor<bfloat16>(x{}):{{x:0}:2.25,{x:1}:1.0,{x:2}:256.0,{x:3}:1.0}"); + var asInt8 = Tensor.from("tensor<int8>(x{}):{{x:0}:2,{x:1}:1,{x:2}:0,{x:3}:1}"); + assertEquals(asFloat, tensor.cellCast(TensorType.Value.FLOAT)); + assertEquals(asBFloat16, tensor.cellCast(TensorType.Value.BFLOAT16)); + assertEquals(asInt8, tensor.cellCast(TensorType.Value.INT8)); + assertEquals(asBFloat16, asFloat.cellCast(TensorType.Value.BFLOAT16)); + assertEquals(asInt8, asFloat.cellCast(TensorType.Value.INT8)); + assertEquals(asInt8, asBFloat16.cellCast(TensorType.Value.INT8)); } } |