summaryrefslogtreecommitdiffstats
path: root/eval
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2018-01-11 11:37:41 +0100
committerGitHub <noreply@github.com>2018-01-11 11:37:41 +0100
commita37084e70fb1d2a588efc478c1e58aa7685e2c72 (patch)
treeeea7156a7ec9e3ba923b57c7296501796596559f /eval
parent36ce12ede6f05199f219a028d6687bab1eee0a6e (diff)
parentc66d5b151f298e819decada390ac4e69e124697b (diff)
Merge pull request #4612 from vespa-engine/balder/some-misc-old-cleanup
Use c++11 for loops and alignment.
Diffstat (limited to 'eval')
-rw-r--r--eval/src/vespa/eval/tensor/sparse/direct_sparse_tensor_builder.h17
-rw-r--r--eval/src/vespa/eval/tensor/sparse/sparse_tensor_address_ref.h13
2 files changed, 13 insertions, 17 deletions
diff --git a/eval/src/vespa/eval/tensor/sparse/direct_sparse_tensor_builder.h b/eval/src/vespa/eval/tensor/sparse/direct_sparse_tensor_builder.h
index c977131fcd3..9ec98b2c11d 100644
--- a/eval/src/vespa/eval/tensor/sparse/direct_sparse_tensor_builder.h
+++ b/eval/src/vespa/eval/tensor/sparse/direct_sparse_tensor_builder.h
@@ -40,8 +40,7 @@ public:
void
copyCells(const Cells &cells_in, const eval::ValueType &cells_in_type)
{
- SparseTensorAddressPadder addressPadder(_type,
- cells_in_type);
+ SparseTensorAddressPadder addressPadder(_type, cells_in_type);
for (const auto &cell : cells_in) {
addressPadder.padAddress(cell.first);
SparseTensorAddressRef oldRef = addressPadder.getAddressRef();
@@ -64,8 +63,7 @@ public:
{
}
- DirectTensorBuilder(const eval::ValueType &type_in,
- const Cells &cells_in)
+ DirectTensorBuilder(const eval::ValueType &type_in, const Cells &cells_in)
: _stash(TensorImplType::STASH_CHUNK_SIZE),
_type(type_in),
_cells()
@@ -94,14 +92,12 @@ public:
}
template <class Function>
- void insertCell(SparseTensorAddressRef address, double value,
- Function &&func)
+ void insertCell(SparseTensorAddressRef address, double value, Function &&func)
{
- SparseTensorAddressRef oldRef(address);
- auto res = _cells.insert(std::make_pair(oldRef, value));
+ auto res = _cells.insert(std::make_pair(address, value));
if (res.second) {
// Replace key with own copy
- res.first->first = SparseTensorAddressRef(oldRef, _stash);
+ res.first->first = SparseTensorAddressRef(address, _stash);
} else {
res.first->second = func(res.first->second, value);
}
@@ -113,8 +109,7 @@ public:
}
template <class Function>
- void insertCell(SparseTensorAddressBuilder &address, double value,
- Function &&func)
+ void insertCell(SparseTensorAddressBuilder &address, double value, Function &&func)
{
insertCell(address.getAddressRef(), value, func);
}
diff --git a/eval/src/vespa/eval/tensor/sparse/sparse_tensor_address_ref.h b/eval/src/vespa/eval/tensor/sparse/sparse_tensor_address_ref.h
index b179b431b94..8533aa29829 100644
--- a/eval/src/vespa/eval/tensor/sparse/sparse_tensor_address_ref.h
+++ b/eval/src/vespa/eval/tensor/sparse/sparse_tensor_address_ref.h
@@ -16,6 +16,11 @@ class SparseTensorAddressRef
const void *_start;
uint32_t _size;
uint32_t _hash;
+ static void * copy(const SparseTensorAddressRef rhs, Stash &stash) {
+ void *res = stash.alloc(rhs._size);
+ memcpy(res, rhs._start, rhs._size);
+ return res;
+ }
public:
SparseTensorAddressRef()
: _start(nullptr), _size(0u), _hash(0u)
@@ -29,14 +34,10 @@ public:
}
SparseTensorAddressRef(const SparseTensorAddressRef rhs, Stash &stash)
- : _start(nullptr),
+ : _start(copy(rhs, stash)),
_size(rhs._size),
_hash(rhs._hash)
- {
- void *res = stash.alloc(rhs._size);
- memcpy(res, rhs._start, rhs._size);
- _start = res;
- }
+ {}
uint32_t hash() const { return _hash; }