diff options
author | Henning Baldersheim <balder@oath.com> | 2019-04-03 05:05:02 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2019-04-03 05:05:02 +0000 |
commit | 6bb8fbba81114e3b7c902b1a9d12f3d91029011e (patch) | |
tree | 0f5133c512f7eb5cc2648ac3064a1961d4e6cdeb /eval/src/tests/tensor/tensor_serialization/tensor_serialization_test.cpp | |
parent | cc9de9ee016dbdbe5379a0871638ce33a3b30266 (diff) |
Instead of specifying type of tensor, specify serialization.
Diffstat (limited to 'eval/src/tests/tensor/tensor_serialization/tensor_serialization_test.cpp')
-rw-r--r-- | eval/src/tests/tensor/tensor_serialization/tensor_serialization_test.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/eval/src/tests/tensor/tensor_serialization/tensor_serialization_test.cpp b/eval/src/tests/tensor/tensor_serialization/tensor_serialization_test.cpp index de860e3b152..d32fecc5cba 100644 --- a/eval/src/tests/tensor/tensor_serialization/tensor_serialization_test.cpp +++ b/eval/src/tests/tensor/tensor_serialization/tensor_serialization_test.cpp @@ -11,11 +11,12 @@ #include <vespa/vespalib/objects/nbostream.h> #include <vespa/vespalib/objects/hexdump.h> #include <ostream> +#include <vespa/eval/tensor/dense/dense_tensor_view.h> using namespace vespalib::tensor; using vespalib::nbostream; using ExpBuffer = std::vector<uint8_t>; -using CellType = vespalib::eval::ValueType::CellType; +using SerializeFormat = vespalib::tensor::DenseTensorView::SerializeFormat; namespace std { @@ -33,9 +34,7 @@ std::ostream &operator<<(std::ostream &out, const std::vector<uint8_t> &rhs) } -namespace vespalib { - -namespace tensor { +namespace vespalib::tensor { static bool operator==(const Tensor &lhs, const Tensor &rhs) { @@ -43,7 +42,6 @@ static bool operator==(const Tensor &lhs, const Tensor &rhs) } } -} template <class BuilderType> void @@ -85,7 +83,7 @@ struct Fixture auto formatId = wrapStream.getInt1_4Bytes(); ASSERT_EQUAL(formatId, 1u); // sparse format SparseBinaryFormat::deserialize(wrapStream, builder); - EXPECT_TRUE(wrapStream.size() == 0); + EXPECT_TRUE(wrapStream.empty()); auto ret = builder.build(); checkDeserialize<BuilderType>(stream, *ret); stream.adjustReadPos(stream.size()); @@ -147,8 +145,10 @@ TEST_F("test tensor serialization for SparseTensor", SparseFixture) struct DenseFixture { - Tensor::UP createTensor(CellType cellType, const DenseTensorCells &cells) { - return TensorFactory::createDense(cellType, cells); + Tensor::UP createTensor(SerializeFormat format, const DenseTensorCells &cells) { + auto tensor = TensorFactory::createDense(cells); + dynamic_cast<DenseTensorView &>(*tensor).serializeAs(format); + return tensor; } void serialize(nbostream &stream, const Tensor &tensor) { @@ -163,9 +163,9 @@ struct DenseFixture return ret; } void assertSerialized(const ExpBuffer &exp, const DenseTensorCells &rhs) { - assertSerialized(exp, CellType::DOUBLE, rhs); + assertSerialized(exp, SerializeFormat::DOUBLE, rhs); } - void assertSerialized(const ExpBuffer &exp, CellType cellType, const DenseTensorCells &rhs) { + void assertSerialized(const ExpBuffer &exp, SerializeFormat cellType, const DenseTensorCells &rhs) { Tensor::UP rhsTensor(createTensor(cellType, rhs)); nbostream rhsStream; serialize(rhsStream, *rhsTensor); @@ -272,7 +272,7 @@ TEST_F("test 'float' cells", DenseFixture) { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00 }, - CellType::FLOAT, { {{{"x",2}, {"y",4}}, 3} })); + SerializeFormat::FLOAT, { {{{"x",2}, {"y",4}}, 3} })); } |