summaryrefslogtreecommitdiffstats
path: root/eval/src/tests
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@oath.com>2019-04-03 05:05:02 +0000
committerHenning Baldersheim <balder@oath.com>2019-04-03 05:05:02 +0000
commit6bb8fbba81114e3b7c902b1a9d12f3d91029011e (patch)
tree0f5133c512f7eb5cc2648ac3064a1961d4e6cdeb /eval/src/tests
parentcc9de9ee016dbdbe5379a0871638ce33a3b30266 (diff)
Instead of specifying type of tensor, specify serialization.
Diffstat (limited to 'eval/src/tests')
-rw-r--r--eval/src/tests/tensor/dense_tensor_builder/dense_tensor_builder_test.cpp2
-rw-r--r--eval/src/tests/tensor/tensor_serialization/tensor_serialization_test.cpp22
2 files changed, 12 insertions, 12 deletions
diff --git a/eval/src/tests/tensor/dense_tensor_builder/dense_tensor_builder_test.cpp b/eval/src/tests/tensor/dense_tensor_builder/dense_tensor_builder_test.cpp
index 323aad3246d..a0aeb6b63c9 100644
--- a/eval/src/tests/tensor/dense_tensor_builder/dense_tensor_builder_test.cpp
+++ b/eval/src/tests/tensor/dense_tensor_builder/dense_tensor_builder_test.cpp
@@ -40,7 +40,7 @@ assertTensorSpec(const TensorSpec &expSpec, const Tensor &tensor)
struct Fixture
{
Builder builder;
- Fixture() : builder(ValueType::CellType::DOUBLE) {}
+ Fixture() : builder() {}
};
Tensor::UP
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} }));
}