diff options
author | Håvard Pettersen <havardpe@oath.com> | 2017-11-28 14:18:16 +0000 |
---|---|---|
committer | Håvard Pettersen <havardpe@oath.com> | 2017-11-28 14:18:16 +0000 |
commit | ccb37dd9a7bc4e6a42bb6084803517945d651d84 (patch) | |
tree | 8a6c22ef4c34472cb35f3353f5b3f02c45aaca9f /eval | |
parent | 361caf80d6e35fb1e4d23afcea97fe64dc56a3f4 (diff) |
remove tensor print/toString (use TensorSpec instead)
Diffstat (limited to 'eval')
-rw-r--r-- | eval/src/vespa/eval/tensor/dense/dense_tensor_view.cpp | 33 | ||||
-rw-r--r-- | eval/src/vespa/eval/tensor/dense/dense_tensor_view.h | 2 | ||||
-rw-r--r-- | eval/src/vespa/eval/tensor/sparse/sparse_tensor.cpp | 45 | ||||
-rw-r--r-- | eval/src/vespa/eval/tensor/sparse/sparse_tensor.h | 2 | ||||
-rw-r--r-- | eval/src/vespa/eval/tensor/tensor.cpp | 2 | ||||
-rw-r--r-- | eval/src/vespa/eval/tensor/tensor.h | 6 | ||||
-rw-r--r-- | eval/src/vespa/eval/tensor/wrapped_simple_tensor.cpp | 12 | ||||
-rw-r--r-- | eval/src/vespa/eval/tensor/wrapped_simple_tensor.h | 2 |
8 files changed, 3 insertions, 101 deletions
diff --git a/eval/src/vespa/eval/tensor/dense/dense_tensor_view.cpp b/eval/src/vespa/eval/tensor/dense/dense_tensor_view.cpp index e245f9a8853..3f647975154 100644 --- a/eval/src/vespa/eval/tensor/dense/dense_tensor_view.cpp +++ b/eval/src/vespa/eval/tensor/dense/dense_tensor_view.cpp @@ -207,14 +207,6 @@ DenseTensorView::equals(const Tensor &arg) const return false; } -vespalib::string -DenseTensorView::toString() const -{ - std::ostringstream stream; - stream << *this; - return stream.str(); -} - Tensor::UP DenseTensorView::clone() const { @@ -250,31 +242,6 @@ DenseTensorView::toSpec() const } void -DenseTensorView::print(std::ostream &out) const -{ - // TODO (geirst): print on common format. - out << "[ "; - bool first = true; - for (const auto &dim : _typeRef.dimensions()) { - if (!first) { - out << ", "; - } - out << dim.name << ":" << dim.size; - first = false; - } - out << " ] { "; - first = true; - for (const auto &cell : cellsRef()) { - if (!first) { - out << ", "; - } - out << cell; - first = false; - } - out << " }"; -} - -void DenseTensorView::accept(TensorVisitor &visitor) const { CellsIterator iterator(_typeRef, _cellsRef); diff --git a/eval/src/vespa/eval/tensor/dense/dense_tensor_view.h b/eval/src/vespa/eval/tensor/dense/dense_tensor_view.h index af32fc0d708..95480210d44 100644 --- a/eval/src/vespa/eval/tensor/dense/dense_tensor_view.h +++ b/eval/src/vespa/eval/tensor/dense/dense_tensor_view.h @@ -59,8 +59,6 @@ public: const std::vector<vespalib::string> &dimensions) const override; virtual bool equals(const Tensor &arg) const override; - virtual void print(std::ostream &out) const override; - virtual vespalib::string toString() const override; virtual Tensor::UP clone() const override; virtual eval::TensorSpec toSpec() const override; virtual void accept(TensorVisitor &visitor) const override; diff --git a/eval/src/vespa/eval/tensor/sparse/sparse_tensor.cpp b/eval/src/vespa/eval/tensor/sparse/sparse_tensor.cpp index 3b71fdafc2d..52d171813ea 100644 --- a/eval/src/vespa/eval/tensor/sparse/sparse_tensor.cpp +++ b/eval/src/vespa/eval/tensor/sparse/sparse_tensor.cpp @@ -33,27 +33,6 @@ copyCells(Cells &cells, const Cells &cells_in, Stash &stash) } } -void -printAddress(std::ostream &out, const SparseTensorAddressRef &ref, - const eval::ValueType &type) -{ - out << "{"; - bool first = true; - SparseTensorAddressDecoder addr(ref); - for (auto &dim : type.dimensions()) { - auto label = addr.decodeLabel(); - if (label.size() != 0u) { - if (!first) { - out << ","; - } - out << dim.name << ":" << label; - first = false; - } - } - assert(!addr.valid()); - out << "}"; -} - } SparseTensor::SparseTensor(const eval::ValueType &type_in, @@ -158,14 +137,6 @@ SparseTensor::equals(const Tensor &arg) const return *this == *rhs; } -vespalib::string -SparseTensor::toString() const -{ - std::ostringstream stream; - stream << *this; - return stream.str(); -} - Tensor::UP SparseTensor::clone() const { @@ -206,22 +177,6 @@ SparseTensor::toSpec() const } void -SparseTensor::print(std::ostream &out) const -{ - out << "{ "; - bool first = true; - for (const auto &cell : cells()) { - if (!first) { - out << ", "; - } - printAddress(out, cell.first, _type); - out << ":" << cell.second; - first = false; - } - out << " }"; -} - -void SparseTensor::accept(TensorVisitor &visitor) const { TensorAddressBuilder addrBuilder; diff --git a/eval/src/vespa/eval/tensor/sparse/sparse_tensor.h b/eval/src/vespa/eval/tensor/sparse/sparse_tensor.h index aa88f8fd6fa..c1c17906fc5 100644 --- a/eval/src/vespa/eval/tensor/sparse/sparse_tensor.h +++ b/eval/src/vespa/eval/tensor/sparse/sparse_tensor.h @@ -53,8 +53,6 @@ public: const std::vector<vespalib::string> &dimensions) const override; virtual bool equals(const Tensor &arg) const override; - virtual void print(std::ostream &out) const override; - virtual vespalib::string toString() const override; virtual Tensor::UP clone() const override; virtual eval::TensorSpec toSpec() const override; virtual void accept(TensorVisitor &visitor) const override; diff --git a/eval/src/vespa/eval/tensor/tensor.cpp b/eval/src/vespa/eval/tensor/tensor.cpp index bbf8dd5017c..8715a864f68 100644 --- a/eval/src/vespa/eval/tensor/tensor.cpp +++ b/eval/src/vespa/eval/tensor/tensor.cpp @@ -30,7 +30,7 @@ Tensor::supported(TypeList types) std::ostream & operator<<(std::ostream &out, const Tensor &value) { - value.print(out); + out << value.toSpec().to_string(); return out; } diff --git a/eval/src/vespa/eval/tensor/tensor.h b/eval/src/vespa/eval/tensor/tensor.h index c47afa4cd8b..5972f3a7957 100644 --- a/eval/src/vespa/eval/tensor/tensor.h +++ b/eval/src/vespa/eval/tensor/tensor.h @@ -39,10 +39,8 @@ struct Tensor : public eval::Tensor virtual Tensor::UP reduce(join_fun_t op, const std::vector<vespalib::string> &dimensions) const = 0; - virtual bool equals(const Tensor &arg) const = 0; - virtual void print(std::ostream &out) const = 0; - virtual vespalib::string toString() const = 0; - virtual Tensor::UP clone() const = 0; + virtual bool equals(const Tensor &arg) const = 0; // want to remove, but needed by document + virtual Tensor::UP clone() const = 0; // want to remove, but needed by document virtual eval::TensorSpec toSpec() const = 0; virtual void accept(TensorVisitor &visitor) const = 0; diff --git a/eval/src/vespa/eval/tensor/wrapped_simple_tensor.cpp b/eval/src/vespa/eval/tensor/wrapped_simple_tensor.cpp index 8f7d75fae82..50c567fa6ea 100644 --- a/eval/src/vespa/eval/tensor/wrapped_simple_tensor.cpp +++ b/eval/src/vespa/eval/tensor/wrapped_simple_tensor.cpp @@ -17,12 +17,6 @@ WrappedSimpleTensor::equals(const Tensor &arg) const return (lhs_spec == rhs_spec); } -vespalib::string -WrappedSimpleTensor::toString() const -{ - return toSpec().to_string(); -} - eval::TensorSpec WrappedSimpleTensor::toSpec() const { @@ -53,12 +47,6 @@ WrappedSimpleTensor::accept(TensorVisitor &visitor) const } } -void -WrappedSimpleTensor::print(std::ostream &out) const -{ - out << toString(); -} - Tensor::UP WrappedSimpleTensor::clone() const { diff --git a/eval/src/vespa/eval/tensor/wrapped_simple_tensor.h b/eval/src/vespa/eval/tensor/wrapped_simple_tensor.h index 71b49793965..fdaf86459da 100644 --- a/eval/src/vespa/eval/tensor/wrapped_simple_tensor.h +++ b/eval/src/vespa/eval/tensor/wrapped_simple_tensor.h @@ -30,11 +30,9 @@ public: const eval::SimpleTensor &get() const { return _tensor; } const eval::ValueType &type() const override { return _tensor.type(); } bool equals(const Tensor &arg) const override; - vespalib::string toString() const override; eval::TensorSpec toSpec() const override; double as_double() const override; void accept(TensorVisitor &visitor) const override; - void print(std::ostream &out) const override; Tensor::UP clone() const override; // functions below should not be used for this implementation Tensor::UP multiply(const Tensor &) const override; |