Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/intgemm/intgemm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolay Bogoychev <nheart@gmail.com>2020-04-20 17:48:24 +0300
committerNikolay Bogoychev <nheart@gmail.com>2020-04-20 17:48:24 +0300
commitcbe5992506fad7f37d71f2518223247d422d17db (patch)
tree98d1145d5b99b78cb3b7311041b6b19b0223c4aa
parentd8124d2c43ee0e702c0b7f2af9f5aec431f97c8c (diff)
Rename and fix interfaceabsolute_std
-rw-r--r--avx2_gemm.h2
-rw-r--r--avx512_gemm.h2
-rw-r--r--intgemm.cc2
-rw-r--r--intgemm.h10
-rw-r--r--multiply.h6
-rw-r--r--sse2_gemm.h2
-rw-r--r--test/quantize_test.cc84
7 files changed, 55 insertions, 53 deletions
diff --git a/avx2_gemm.h b/avx2_gemm.h
index 41f705b..68eb37e 100644
--- a/avx2_gemm.h
+++ b/avx2_gemm.h
@@ -192,7 +192,7 @@ class QuantizeTile8 {
// Technically only requires AVX
INTGEMM_MAXABSOLUTE(__m256, INTGEMM_AVX2)
-INTGEMM_EUCLIDEANNORM(__m256, INTGEMM_AVX2)
+INTGEMM_VECTORMEANSTD(__m256, INTGEMM_AVX2)
} // namespace
diff --git a/avx512_gemm.h b/avx512_gemm.h
index 7488ff2..a0087b3 100644
--- a/avx512_gemm.h
+++ b/avx512_gemm.h
@@ -159,7 +159,7 @@ class QuantizeTile8 {
/* Only INTGEMM_AVX512F is necessary but due to GCC 5.4 bug we have to set INTGEMM_AVX512BW */
INTGEMM_MAXABSOLUTE(__m512, INTGEMM_AVX512BW)
-INTGEMM_EUCLIDEANNORM(__m512, INTGEMM_AVX512BW)
+INTGEMM_VECTORMEANSTD(__m512, INTGEMM_AVX512BW)
} // namespace
diff --git a/intgemm.cc b/intgemm.cc
index c959105..05337c8 100644
--- a/intgemm.cc
+++ b/intgemm.cc
@@ -40,7 +40,7 @@ const CPUType kCPU = ChooseCPU(CPUType::AVX512VNNI, CPUType::AVX512BW, CPUType::
float (*MaxAbsolute)(const float *begin, const float *end) = ChooseCPU(avx512f::MaxAbsolute, avx512f::MaxAbsolute, avx2::MaxAbsolute, sse2::MaxAbsolute, sse2::MaxAbsolute, Unsupported_MaxAbsolute);
-MeanStd (*EuclideanNorm)(const float *begin, const float *end, bool absolute) = ChooseCPU(avx512f::EuclideanNorm, avx512f::EuclideanNorm, avx2::EuclideanNorm, sse2::EuclideanNorm, sse2::EuclideanNorm, sse2::EuclideanNorm);
+MeanStd (*VectorMeanStd)(const float *begin, const float *end, bool absolute) = ChooseCPU(avx512f::VectorMeanStd, avx512f::VectorMeanStd, avx2::VectorMeanStd, sse2::VectorMeanStd, sse2::VectorMeanStd, sse2::VectorMeanStd);
constexpr const char *const Unsupported_16bit::kName;
constexpr const char *const Unsupported_8bit::kName;
diff --git a/intgemm.h b/intgemm.h
index daf94dd..3bd6af8 100644
--- a/intgemm.h
+++ b/intgemm.h
@@ -128,7 +128,7 @@ namespace avx512f {
static inline float MaxAbsolute(const float * /*begin*/, const float * /*end*/) {
throw UnsupportedCPU();
}
-static inline MeanStd QuantizerStd(const float * /*begin*/, const float * /*end*/, bool) {
+static inline MeanStd EuclideanNorm(const float * /*begin*/, const float * /*end*/, bool) {
throw UnsupportedCPU();
}
} //namespace
@@ -420,10 +420,12 @@ extern const CPUType kCPU;
extern float (*MaxAbsolute)(const float *begin, const float *end);
// Get a Quantization value that is equant to the mean of the data +N standard deviations. Use 2 by default
-extern MeanStd (*EuclideanNorm)(const float *begin, const float *end, bool);
+extern MeanStd (*VectorMeanStd)(const float *begin, const float *end, bool);
-static inline MeanStd GetQuantizerStd(const float * begin, const float * end, bool absolute=false) {
- return EuclideanNorm(begin, end, absolute);
+/* Returns the Mean and the Standard deviation of a vector.
+ * If "absolute" is set to true, it computes the mean and the standard deviation of the absolute values of the vector */
+static inline MeanStd GetVectorMeanStd(const float * begin, const float * end, bool absolute=false) {
+ return VectorMeanStd(begin, end, absolute);
}
diff --git a/multiply.h b/multiply.h
index 0514bca..9047697 100644
--- a/multiply.h
+++ b/multiply.h
@@ -665,8 +665,8 @@ target static inline float MaxAbsolute(const float *begin_float, const float *en
return ret; \
} \
-#define INTGEMM_EUCLIDEANNORM(Register, target) \
-target static inline MeanStd EuclideanNorm(const float *begin_float, const float *end_float, bool absolute) { \
+#define INTGEMM_VECTORMEANSTD(Register, target) \
+target static inline MeanStd VectorMeanStd(const float *begin_float, const float *end_float, bool absolute) { \
/* Computes the euclidean norm and returns the mean and the standard deviation. Optionally it can be the mean and standard deviation in absolute terms. */ \
assert(end_float > begin_float); \
assert((end_float - begin_float) % (sizeof(Register) / sizeof(float)) == 0); \
@@ -679,7 +679,7 @@ target static inline MeanStd EuclideanNorm(const float *begin_float, const float
const Register mask = set1_ps<Register>(-0.f); \
for (; begin != end; begin++) { \
Register vec = *begin; \
- vec = andnot_ps(mask, vec); \
+ vec = andnot_ps(mask, vec); \
squares = add_ps(squares, mul_ps(vec, vec)); \
sums = add_ps(sums, vec); \
} \
diff --git a/sse2_gemm.h b/sse2_gemm.h
index 84b2f27..8b8f1c2 100644
--- a/sse2_gemm.h
+++ b/sse2_gemm.h
@@ -53,7 +53,7 @@ class QuantizeTile16 {
INTGEMM_MAXABSOLUTE(__m128, INTGEMM_SSE2)
-INTGEMM_EUCLIDEANNORM(__m128, INTGEMM_SSE2)
+INTGEMM_VECTORMEANSTD(__m128, INTGEMM_SSE2)
} //namespace
// This should be pure INTGEMM_SSE2 (and below).
diff --git a/test/quantize_test.cc b/test/quantize_test.cc
index 9e99274..d2046f6 100644
--- a/test/quantize_test.cc
+++ b/test/quantize_test.cc
@@ -30,7 +30,7 @@ void QuantizeRef(const float *input, int8_t *output, float quant_mult, std::size
}
}
-MeanStd EuclideanNorm(AlignedVector<float>& vals, int num_items, bool absolute) {
+MeanStd VectorMeanStd(AlignedVector<float>& vals, int num_items, bool absolute) {
float normal_sums = 0;
float squares_sum = 0;
if (absolute) {
@@ -47,7 +47,7 @@ MeanStd EuclideanNorm(AlignedVector<float>& vals, int num_items, bool absolute)
}
template <MeanStd (*Backend) (const float *, const float *, bool)>
-void testEuclideanNorm(int num_items, bool absolute=false) {
+void testVectorMeanStd(int num_items, bool absolute=false) {
std::mt19937 gen;
std::uniform_real_distribution<float> dist(-1.0f, 1.0f);
AlignedVector<float> inputVec(num_items);
@@ -56,7 +56,7 @@ void testEuclideanNorm(int num_items, bool absolute=false) {
it = dist(gen);
}
- MeanStd reference = EuclideanNorm(inputVec, num_items, absolute);
+ MeanStd reference = VectorMeanStd(inputVec, num_items, absolute);
MeanStd fast = Backend(inputVec.begin(), inputVec.end(), absolute);
float meanDifference = fabs(reference.mean - fast.mean);
@@ -132,53 +132,53 @@ TEST_CASE ("Quantize AVX2", "[quantize]") {
}
#endif
-TEST_CASE("QuantizeStd SSSE3", "[EuclideanNorm]") {
+TEST_CASE("QuantizeStd SSSE3", "[VectorMeanStd]") {
if (kCPU < CPUType::SSSE3) return;
- testEuclideanNorm<sse2::EuclideanNorm>(64);
- testEuclideanNorm<sse2::EuclideanNorm>(64, true);
- testEuclideanNorm<sse2::EuclideanNorm>(256);
- testEuclideanNorm<sse2::EuclideanNorm>(256, true);
- testEuclideanNorm<sse2::EuclideanNorm>(2048);
- testEuclideanNorm<sse2::EuclideanNorm>(2048, true);
- testEuclideanNorm<sse2::EuclideanNorm>(65536);
- testEuclideanNorm<sse2::EuclideanNorm>(65536, true);
- testEuclideanNorm<sse2::EuclideanNorm>(81920);
- testEuclideanNorm<sse2::EuclideanNorm>(81920, true);
- testEuclideanNorm<sse2::EuclideanNorm>(120832);
- testEuclideanNorm<sse2::EuclideanNorm>(120832, true);
+ testVectorMeanStd<sse2::VectorMeanStd>(64);
+ testVectorMeanStd<sse2::VectorMeanStd>(64, true);
+ testVectorMeanStd<sse2::VectorMeanStd>(256);
+ testVectorMeanStd<sse2::VectorMeanStd>(256, true);
+ testVectorMeanStd<sse2::VectorMeanStd>(2048);
+ testVectorMeanStd<sse2::VectorMeanStd>(2048, true);
+ testVectorMeanStd<sse2::VectorMeanStd>(65536);
+ testVectorMeanStd<sse2::VectorMeanStd>(65536, true);
+ testVectorMeanStd<sse2::VectorMeanStd>(81920);
+ testVectorMeanStd<sse2::VectorMeanStd>(81920, true);
+ testVectorMeanStd<sse2::VectorMeanStd>(120832);
+ testVectorMeanStd<sse2::VectorMeanStd>(120832, true);
}
-TEST_CASE("QuantizeStd AVX2", "[EuclideanNorm]") {
+TEST_CASE("QuantizeStd AVX2", "[VectorMeanStd]") {
if (kCPU < CPUType::AVX2) return;
- testEuclideanNorm<avx2::EuclideanNorm>(64);
- testEuclideanNorm<avx2::EuclideanNorm>(64, true);
- testEuclideanNorm<avx2::EuclideanNorm>(256);
- testEuclideanNorm<avx2::EuclideanNorm>(256, true);
- testEuclideanNorm<avx2::EuclideanNorm>(2048);
- testEuclideanNorm<avx2::EuclideanNorm>(2048, true);
- testEuclideanNorm<avx2::EuclideanNorm>(65536);
- testEuclideanNorm<avx2::EuclideanNorm>(65536, true);
- testEuclideanNorm<avx2::EuclideanNorm>(81920);
- testEuclideanNorm<avx2::EuclideanNorm>(81920, true);
- testEuclideanNorm<avx2::EuclideanNorm>(120832);
- testEuclideanNorm<avx2::EuclideanNorm>(120832, true);
+ testVectorMeanStd<avx2::VectorMeanStd>(64);
+ testVectorMeanStd<avx2::VectorMeanStd>(64, true);
+ testVectorMeanStd<avx2::VectorMeanStd>(256);
+ testVectorMeanStd<avx2::VectorMeanStd>(256, true);
+ testVectorMeanStd<avx2::VectorMeanStd>(2048);
+ testVectorMeanStd<avx2::VectorMeanStd>(2048, true);
+ testVectorMeanStd<avx2::VectorMeanStd>(65536);
+ testVectorMeanStd<avx2::VectorMeanStd>(65536, true);
+ testVectorMeanStd<avx2::VectorMeanStd>(81920);
+ testVectorMeanStd<avx2::VectorMeanStd>(81920, true);
+ testVectorMeanStd<avx2::VectorMeanStd>(120832);
+ testVectorMeanStd<avx2::VectorMeanStd>(120832, true);
}
#ifdef INTGEMM_COMPILER_SUPPORTS_AVX512BW
-TEST_CASE("QuantizeStd AVX512", "[EuclideanNorm]") {
+TEST_CASE("QuantizeStd AVX512", "[VectorMeanStd]") {
if (kCPU < CPUType::AVX512BW) return;
- testEuclideanNorm<avx512f::EuclideanNorm>(64);
- testEuclideanNorm<avx512f::EuclideanNorm>(64, true);
- testEuclideanNorm<avx512f::EuclideanNorm>(256);
- testEuclideanNorm<avx512f::EuclideanNorm>(256, true);
- testEuclideanNorm<avx512f::EuclideanNorm>(2048);
- testEuclideanNorm<avx512f::EuclideanNorm>(2048, true);
- testEuclideanNorm<avx512f::EuclideanNorm>(65536);
- testEuclideanNorm<avx512f::EuclideanNorm>(65536, true);
- testEuclideanNorm<avx512f::EuclideanNorm>(81920);
- testEuclideanNorm<avx512f::EuclideanNorm>(81920, true);
- testEuclideanNorm<avx512f::EuclideanNorm>(120832);
- testEuclideanNorm<avx512f::EuclideanNorm>(120832, true);
+ testVectorMeanStd<avx512f::VectorMeanStd>(64);
+ testVectorMeanStd<avx512f::VectorMeanStd>(64, true);
+ testVectorMeanStd<avx512f::VectorMeanStd>(256);
+ testVectorMeanStd<avx512f::VectorMeanStd>(256, true);
+ testVectorMeanStd<avx512f::VectorMeanStd>(2048);
+ testVectorMeanStd<avx512f::VectorMeanStd>(2048, true);
+ testVectorMeanStd<avx512f::VectorMeanStd>(65536);
+ testVectorMeanStd<avx512f::VectorMeanStd>(65536, true);
+ testVectorMeanStd<avx512f::VectorMeanStd>(81920);
+ testVectorMeanStd<avx512f::VectorMeanStd>(81920, true);
+ testVectorMeanStd<avx512f::VectorMeanStd>(120832);
+ testVectorMeanStd<avx512f::VectorMeanStd>(120832, true);
}
#endif