Skip to content

Commit a60daf9

Browse files
author
cflint
committed
add default create for sketch classes
1 parent 8cac6ca commit a60daf9

6 files changed

Lines changed: 48 additions & 0 deletions

File tree

core/sketch/count_sketch.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ CountSketch<ValueType, IndexType>::create(
5050
}
5151

5252

53+
template <typename ValueType, typename IndexType>
54+
std::unique_ptr<CountSketch<ValueType, IndexType>>
55+
CountSketch<ValueType, IndexType>::create(
56+
std::shared_ptr<const Executor> exec)
57+
{
58+
return std::unique_ptr<CountSketch>{new CountSketch(exec)};
59+
}
60+
61+
5362
template <typename ValueType, typename IndexType>
5463
void CountSketch<ValueType, IndexType>::apply_sketch_impl(
5564
const matrix::Dense<ValueType>* b, matrix::Dense<ValueType>* x) const

core/sketch/gaussian_sketch.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ std::unique_ptr<GaussianSketch<ValueType>> GaussianSketch<ValueType>::create(
5151
}
5252

5353

54+
55+
template <typename ValueType>
56+
std::unique_ptr<GaussianSketch<ValueType>> GaussianSketch<ValueType>::create(
57+
std::shared_ptr<const Executor> exec)
58+
{
59+
return std::unique_ptr<GaussianSketch>{new GaussianSketch(exec)};
60+
}
61+
62+
5463
template <typename ValueType>
5564
void GaussianSketch<ValueType>::apply_sketch_impl(
5665
const matrix::Dense<ValueType>* b, matrix::Dense<ValueType>* x) const

core/sketch/sparse_stack.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ SparseStack<ValueType, IndexType>::create(std::shared_ptr<const Executor> exec,
5151
new SparseStack(exec, sketch_size, input_size, zeta, seed)};
5252
}
5353

54+
template <typename ValueType, typename IndexType>
55+
std::unique_ptr<SparseStack<ValueType, IndexType>>
56+
SparseStack<ValueType, IndexType>::create(std::shared_ptr<const Executor> exec)
57+
{
58+
return std::unique_ptr<SparseStack>{new SparseStack(exec)};
59+
}
60+
5461

5562
template <typename ValueType, typename IndexType>
5663
void SparseStack<ValueType, IndexType>::apply_sketch_impl(

include/ginkgo/core/sketch/count_sketch.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ class CountSketch
5353
std::shared_ptr<const Executor> exec, size_type sketch_size,
5454
size_type input_size, uint64 seed);
5555

56+
/**
57+
* Creates an uninitialized CountSketch operator.
58+
*
59+
* @param exec executor where the sketch lives
60+
*/
61+
static std::unique_ptr<CountSketch> create(
62+
std::shared_ptr<const Executor> exec);
63+
5664
/** Returns the random seed. */
5765
uint64 get_seed() const { return seed_; }
5866

include/ginkgo/core/sketch/gaussian_sketch.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ class GaussianSketch
5252
std::shared_ptr<const Executor> exec, size_type sketch_size,
5353
size_type input_size, uint64 seed);
5454

55+
/**
56+
* Creates an uninitialized GaussianSketch operator.
57+
*
58+
* @param exec executor where the sketch lives
59+
*/
60+
static std::unique_ptr<GaussianSketch> create(
61+
std::shared_ptr<const Executor> exec);
62+
5563
/** Returns the random seed used to generate this sketch. */
5664
uint64 get_seed() const { return seed_; }
5765

include/ginkgo/core/sketch/sparse_stack.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ class SparseStack : public EnableLinOp<SparseStack<ValueType, IndexType>,
5353
static std::unique_ptr<SparseStack> create(
5454
std::shared_ptr<const Executor> exec, size_type sketch_size,
5555
size_type input_size, size_type zeta, uint64 seed);
56+
57+
/**
58+
* Creates an uninitialized SparseStack operator.
59+
*
60+
* @param exec executor where the sketch lives
61+
*/
62+
static std::unique_ptr<SparseStack> create(std::shared_ptr<const Executor> exec);
5663

5764
/** Returns the random seed. */
5865
uint64 get_seed() const { return seed_; }

0 commit comments

Comments
 (0)