summaryrefslogtreecommitdiffstats
path: root/eval
diff options
context:
space:
mode:
authorArne Juul <arnej@yahoo-inc.com>2019-06-24 12:41:25 +0000
committerArne Juul <arnej@yahoo-inc.com>2019-06-24 12:41:25 +0000
commitdc7b7062eac653dd33f559bd998a2da892934f63 (patch)
treefbd49d7341c76c60aa3f7053998ee12176e80256 /eval
parent98ffc28bceaaaa47f1213283ed6bee1e9d1a2bac (diff)
GC unused class
Diffstat (limited to 'eval')
-rw-r--r--eval/CMakeLists.txt1
-rw-r--r--eval/src/tests/tensor/dense_tensor_address_combiner/CMakeLists.txt8
-rw-r--r--eval/src/tests/tensor/dense_tensor_address_combiner/dense_tensor_address_combiner_test.cpp32
-rw-r--r--eval/src/vespa/eval/tensor/dense/CMakeLists.txt5
-rw-r--r--eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.cpp63
-rw-r--r--eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.h123
6 files changed, 2 insertions, 230 deletions
diff --git a/eval/CMakeLists.txt b/eval/CMakeLists.txt
index 92fdd2f9162..e0159febdfe 100644
--- a/eval/CMakeLists.txt
+++ b/eval/CMakeLists.txt
@@ -33,7 +33,6 @@ vespa_define_module(
src/tests/tensor/dense_inplace_map_function
src/tests/tensor/dense_remove_dimension_optimizer
src/tests/tensor/dense_replace_type_function
- src/tests/tensor/dense_tensor_address_combiner
src/tests/tensor/dense_xw_product_function
src/tests/tensor/direct_dense_tensor_builder
src/tests/tensor/direct_sparse_tensor_builder
diff --git a/eval/src/tests/tensor/dense_tensor_address_combiner/CMakeLists.txt b/eval/src/tests/tensor/dense_tensor_address_combiner/CMakeLists.txt
deleted file mode 100644
index a006d70935d..00000000000
--- a/eval/src/tests/tensor/dense_tensor_address_combiner/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-vespa_add_executable(eval_dense_tensor_address_combiner_test_app TEST
- SOURCES
- dense_tensor_address_combiner_test.cpp
- DEPENDS
- vespaeval
-)
-vespa_add_test(NAME eval_dense_tensor_address_combiner_test_app COMMAND eval_dense_tensor_address_combiner_test_app)
diff --git a/eval/src/tests/tensor/dense_tensor_address_combiner/dense_tensor_address_combiner_test.cpp b/eval/src/tests/tensor/dense_tensor_address_combiner/dense_tensor_address_combiner_test.cpp
deleted file mode 100644
index 91a6087ea3a..00000000000
--- a/eval/src/tests/tensor/dense_tensor_address_combiner/dense_tensor_address_combiner_test.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/eval/tensor/dense/dense_tensor_address_combiner.h>
-#include <vespa/vespalib/test/insertion_operators.h>
-
-using namespace vespalib::tensor;
-using vespalib::eval::ValueType;
-
-ValueType
-combine(const std::vector<ValueType::Dimension> &lhs,
- const std::vector<ValueType::Dimension> &rhs)
-{
- return DenseTensorAddressCombiner::combineDimensions(
- ValueType::tensor_type(lhs),
- ValueType::tensor_type(rhs));
-}
-
-TEST("require that dimensions can be combined")
-{
- EXPECT_EQUAL(ValueType::tensor_type({{"a", 3}, {"b", 5}}), combine({{"a", 3}}, {{"b", 5}}));
- EXPECT_EQUAL(ValueType::tensor_type({{"a", 3}, {"b", 5}}), combine({{"a", 3}, {"b", 5}}, {{"b", 5}}));
- EXPECT_EQUAL(ValueType::tensor_type({{"a", 3}, {"b", 5}}), combine({{"a", 3}, {"b", 5}}, {{"b", 5}}));
- EXPECT_EQUAL(ValueType::tensor_type({{"a", 3}, {"b", 11}, {"c", 5}, {"d", 7}, {"e", 17}}),
- combine({{"a", 3}, {"c", 5}, {"d", 7}},
- {{"b", 11}, {"c", 5}, {"e", 17}}));
- EXPECT_EQUAL(ValueType::tensor_type({{"a", 3}, {"b", 11}, {"c", 5}, {"d", 7}, {"e", 17}}),
- combine({{"b", 11}, {"c", 5}, {"e", 17}},
- {{"a", 3}, {"c", 5}, {"d", 7}}));
-}
-
-TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/eval/src/vespa/eval/tensor/dense/CMakeLists.txt b/eval/src/vespa/eval/tensor/dense/CMakeLists.txt
index 3fcf51da839..ce20d6ba6d9 100644
--- a/eval/src/vespa/eval/tensor/dense/CMakeLists.txt
+++ b/eval/src/vespa/eval/tensor/dense/CMakeLists.txt
@@ -1,18 +1,17 @@
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
vespa_add_library(eval_tensor_dense OBJECT
SOURCES
- dense_dimension_combiner.cpp
dense_add_dimension_optimizer.cpp
+ dense_dimension_combiner.cpp
dense_dot_product_function.cpp
dense_fast_rename_optimizer.cpp
dense_inplace_join_function.cpp
dense_inplace_map_function.cpp
dense_remove_dimension_optimizer.cpp
dense_replace_type_function.cpp
- dense_tensor.cpp
- dense_tensor_address_combiner.cpp
dense_tensor_address_mapper.cpp
dense_tensor_cells_iterator.cpp
+ dense_tensor.cpp
dense_tensor_modify.cpp
dense_tensor_reduce.cpp
dense_tensor_view.cpp
diff --git a/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.cpp b/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.cpp
deleted file mode 100644
index b5c5d9b6a04..00000000000
--- a/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-#include "dense_tensor_address_combiner.h"
-#include <vespa/vespalib/util/exceptions.h>
-#include <cassert>
-
-namespace vespalib::tensor {
-
-DenseTensorAddressCombiner::~DenseTensorAddressCombiner() = default;
-
-DenseTensorAddressCombiner::DenseTensorAddressCombiner(const eval::ValueType &combined, const eval::ValueType &lhs,
- const eval::ValueType &rhs)
- : _rightAddress(rhs),
- _combinedAddress(combined),
- _left(),
- _commonRight(),
- _right()
-{
- auto rhsItr = rhs.dimensions().cbegin();
- auto rhsItrEnd = rhs.dimensions().cend();
- uint32_t numDimensions(0);
- for (const auto &lhsDim : lhs.dimensions()) {
- while ((rhsItr != rhsItrEnd) && (rhsItr->name < lhsDim.name)) {
- _right.emplace_back(numDimensions++, rhsItr-rhs.dimensions().cbegin());
- ++rhsItr;
- }
- if ((rhsItr != rhsItrEnd) && (rhsItr->name == lhsDim.name)) {
- _left.emplace_back(numDimensions, _left.size());
- _commonRight.emplace_back(numDimensions, rhsItr-rhs.dimensions().cbegin());
- ++numDimensions;
- ++rhsItr;
- } else {
- _left.emplace_back(numDimensions++, _left.size());
- }
- }
- while (rhsItr != rhsItrEnd) {
- _right.emplace_back(numDimensions++, rhsItr-rhs.dimensions().cbegin());
- ++rhsItr;
- }
-}
-
-AddressContext::AddressContext(const eval::ValueType &type)
- : _type(type),
- _accumulatedSize(_type.dimensions().size()),
- _address(type.dimensions().size(), 0)
-
-{
- size_t multiplier = 1;
- for (int32_t i(_address.size() - 1); i >= 0; i--) {
- _accumulatedSize[i] = multiplier;
- multiplier *= type.dimensions()[i].size;
- }
-}
-
-AddressContext::~AddressContext() = default;
-
-eval::ValueType
-DenseTensorAddressCombiner::combineDimensions(const eval::ValueType &lhs, const eval::ValueType &rhs)
-{
- return eval::ValueType::join(lhs, rhs);
-}
-
-}
diff --git a/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.h b/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.h
deleted file mode 100644
index 3f6e347490c..00000000000
--- a/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.h
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-#pragma once
-
-#include "dense_tensor_cells_iterator.h"
-#include <vespa/eval/tensor/tensor.h>
-#include <vespa/eval/tensor/types.h>
-#include <vespa/eval/eval/value_type.h>
-
-namespace vespalib::tensor {
-
-class AddressContext {
-public:
- using Address = DenseTensorCellsIterator::Address;
- using size_type = eval::ValueType::Dimension::size_type;
- using Mapping = std::vector<std::pair<uint32_t, uint32_t>>;
- AddressContext(const eval::ValueType &type);
- ~AddressContext();
- size_type dimSize(uint32_t dim) const { return _type.dimensions()[dim].size; }
- size_type wholeDimStep(uint32_t dim) const { return _accumulatedSize[dim] * dimSize(dim); }
- size_t index() const {
- size_t cellIdx(0);
- for (uint32_t i(0); i < _address.size(); i++) {
- cellIdx += _address[i]*_accumulatedSize[i];
- }
- return cellIdx;
- }
- void update(const Address & addr, const Mapping & mapping) {
- for (const auto & m : mapping) {
- _address[m.first] = addr[m.second];
- }
- }
- bool updateCommon(const Address & addr, const Mapping & mapping) {
- for (const auto & m : mapping) {
- if (addr[m.first] >= dimSize(m.second)) {
- return false;
- }
- _address[m.second] = addr[m.first];
- }
- return true;
- }
-
- const eval::ValueType &_type;
- std::vector<size_t> _accumulatedSize;
- Address _address;
-
-};
-
-/**
- * Combines two dense tensor addresses to a new tensor address.
- * The resulting dimensions is the union of the input dimensions and
- * common dimensions must have matching labels.
- */
-class DenseTensorAddressCombiner
-{
-public:
- using Mapping = AddressContext::Mapping;
-
-private:
- using Address = DenseTensorCellsIterator::Address;
- using CellsRef = vespalib::ConstArrayRef<double>;
- using size_type = eval::ValueType::Dimension::size_type;
-
- AddressContext _rightAddress;
- AddressContext _combinedAddress;
-
- Mapping _left;
- Mapping _commonRight;
- Mapping _right;
-
-public:
- DenseTensorAddressCombiner(const eval::ValueType &combined, const eval::ValueType &lhs, const eval::ValueType &rhs);
- ~DenseTensorAddressCombiner();
- void updateLeftAndCommon(const Address & addr) { _combinedAddress.update(addr, _left); }
- bool updateCommon() { return _rightAddress.updateCommon(_combinedAddress._address, _commonRight); }
- bool hasAnyRightOnlyDimensions() const { return ! _right.empty(); }
-
- const Address & address() const { return _combinedAddress._address; }
- size_t rightCellIndex() const { return _rightAddress.index(); }
-
- template <typename Func>
- void for_each_right(const CellsRef & rhsCells, Func && func) {
- // The rightAddress oly holds the starting point for iteration and what is need to efficiently maintain
- // an index for addressing th ecells.
- const int32_t lastDimension = _right.size() - 1;
- int32_t curDimension = lastDimension;
- size_t rightCellIdx = _rightAddress.index();
- size_t combinedCellIdx = _combinedAddress.index();
- while (curDimension >= 0) {
- const uint32_t rdim = _right[curDimension].second;
- const uint32_t cdim = _right[curDimension].first;
- size_type & cindex = _combinedAddress._address[cdim];
- if (curDimension == lastDimension) {
- for (cindex = 0; cindex < _rightAddress.dimSize(rdim); cindex++) {
- func(combinedCellIdx, rhsCells[rightCellIdx]);
- rightCellIdx += _rightAddress._accumulatedSize[rdim];
- combinedCellIdx += _combinedAddress._accumulatedSize[cdim];
- }
- cindex = 0;
- rightCellIdx -= _rightAddress.wholeDimStep(rdim);
- combinedCellIdx -= _combinedAddress.wholeDimStep(cdim);
- curDimension--;
- } else {
- if ((cindex + 1) < _rightAddress.dimSize(rdim)) {
- cindex++;
- rightCellIdx += _rightAddress._accumulatedSize[rdim];
- combinedCellIdx += _combinedAddress._accumulatedSize[cdim];
- curDimension++;
- } else {
- rightCellIdx -= _rightAddress.wholeDimStep(rdim);
- combinedCellIdx -= _combinedAddress.wholeDimStep(cdim);
- cindex = 0;
- curDimension--;
- }
- }
- }
- }
-
- static eval::ValueType combineDimensions(const eval::ValueType &lhs, const eval::ValueType &rhs);
-};
-
-
-}