aboutsummaryrefslogtreecommitdiff
path: root/public/map.h
diff options
context:
space:
mode:
authorMiao Wang <miaowang@google.com>2015-10-19 15:30:10 -0700
committerMiao Wang <miaowang@google.com>2016-02-03 11:19:49 -0800
commit7b05d573cf2e0fd3a58e98cdbfc65153a83fd6f1 (patch)
tree5ff593d7c6f5798eaeb8708482c3af11b7021183 /public/map.h
parent963b3cb31bd43460e5879d9f70e2f0636183634e (diff)
downloadgemmlowp-7b05d573cf2e0fd3a58e98cdbfc65153a83fd6f1.tar.gz
Rebase gemmlowp to e96c3a9android-n-preview-1
- Better multi-thread perf - API change to match standard GEMM: C=A*B rather than C=B*A Change-Id: I74159fcb246d2a1fc246015e221306bbe11ea8e3
Diffstat (limited to 'public/map.h')
-rw-r--r--public/map.h51
1 files changed, 48 insertions, 3 deletions
diff --git a/public/map.h b/public/map.h
index 2d78ed9..ce6428e 100644
--- a/public/map.h
+++ b/public/map.h
@@ -19,6 +19,7 @@
#define GEMMLOWP_PUBLIC_MAP_H_
#include "../internal/common.h"
+#include "../internal/iterator.h"
namespace gemmlowp {
@@ -39,9 +40,9 @@ class MatrixMap {
int rows_, cols_, stride_;
public:
+ MatrixMap() : data_(nullptr), rows_(0), cols_(0), stride_(0) {}
MatrixMap(Scalar* data, int rows, int cols, int stride)
: data_(data), rows_(rows), cols_(cols), stride_(stride) {}
-
MatrixMap(const MatrixMap& other)
: data_(other.data_),
rows_(other.rows_),
@@ -57,8 +58,7 @@ class MatrixMap {
Scalar* data(int row, int col) const {
return data_ + row * rows_stride() + col * cols_stride();
}
- Scalar operator()(int row, int col) const { return *data(row, col); }
- Scalar& operator()(int row, int col) { return *data(row, col); }
+ Scalar& operator()(int row, int col) const { return *data(row, col); }
MatrixMap block(int start_row, int start_col, int block_rows,
int block_cols) const {
@@ -72,6 +72,51 @@ class MatrixMap {
}
};
+enum class VectorShape { Col, Row };
+
+// A VectorMap is a view of an existing buffer as a vector. It does not own
+// the buffer.
+template <typename tScalar, VectorShape tShape>
+class VectorMap {
+ public:
+ typedef tScalar Scalar;
+ static const VectorShape kShape = tShape;
+
+ protected:
+ Scalar* data_; // not owned.
+ int size_;
+
+ public:
+ VectorMap() : data_(nullptr), size_(0) {}
+ VectorMap(Scalar* data, int size) : data_(data), size_(size) {}
+ VectorMap(const VectorMap& other) : data_(other.data_), size_(other.size_) {}
+
+ int size() const { return size_; }
+ Scalar* data() const { return data_; }
+ Scalar* data(int index) const { return data_ + index; }
+ Scalar& operator()(int index) const { return *data(index); }
+};
+
+// A VectorDup is a (duplicated value) vector where all components are the same.
+template <typename tScalar, VectorShape tShape>
+class VectorDup {
+ public:
+ typedef tScalar Scalar;
+ static const VectorShape kShape = tShape;
+
+ protected:
+ Scalar data_;
+ int size_;
+
+ public:
+ VectorDup() : data_(0), size_(0) {}
+ VectorDup(Scalar data, int size) : data_(data), size_(size) {}
+ VectorDup(const VectorDup& other) : data_(other.data_), size_(other.size_) {}
+
+ int size() const { return size_; }
+ Scalar& operator()(int index) const { return data_; }
+};
+
} // namespace gemmlowp
#endif // GEMMLOWP_PUBLIC_MAP_H_