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

github.com/marian-nmt/intgemm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Chudyk <mateuszchudyk@gmail.com>2020-02-05 19:27:14 +0300
committerMateusz Chudyk <mateuszchudyk@gmail.com>2020-02-05 19:38:25 +0300
commitd9c1cc53363b2ab03a87ac094b3358d5fce7c61d (patch)
treef61a439a2215a859612a190befd315c871327bf1
parentfc816e0b6b2eeb94cc14f80c38ea3fb75a5518d7 (diff)
Add PrepareBTransposed in API
-rw-r--r--intgemm.cc4
-rw-r--r--intgemm.h18
2 files changed, 20 insertions, 2 deletions
diff --git a/intgemm.cc b/intgemm.cc
index 850bb4e..43b8ca6 100644
--- a/intgemm.cc
+++ b/intgemm.cc
@@ -12,6 +12,8 @@ void (*Int16::PrepareB)(const float *input, int16_t *output, float quant_mult, I
void (*Int16::PrepareBQuantizedTransposed)(const int16_t *input, int16_t *output, Index inner, Index B_untransposed_cols) = ChooseCPU(AVX512_16bit::PrepareBQuantizedTransposed, AVX512_16bit::PrepareBQuantizedTransposed, AVX2_16bit::PrepareBQuantizedTransposed, SSE2_16bit::PrepareBQuantizedTransposed, SSE2_16bit::PrepareBQuantizedTransposed, Unsupported_16bit::PrepareBQuantizedTransposed);
+void (*Int16::PrepareBTransposed)(const float *input, int16_t *output, float quant_mult, Index inner, Index B_untransposed_cols) = ChooseCPU(AVX512_16bit::PrepareBTransposed, AVX512_16bit::PrepareBTransposed, AVX2_16bit::PrepareBTransposed, SSE2_16bit::PrepareBTransposed, SSE2_16bit::PrepareBTransposed, Unsupported_16bit::PrepareBTransposed);
+
void (*Int16::SelectColumnsB)(const int16_t *input, int16_t *output, Index rows, const Index *cols_begin, const Index *cols_end) = ChooseCPU(AVX512_16bit::SelectColumnsB, AVX512_16bit::SelectColumnsB, AVX2_16bit::SelectColumnsB, SSE2_16bit::SelectColumnsB, SSE2_16bit::SelectColumnsB, Unsupported_16bit::SelectColumnsB);
const char *const Int16::kName = ChooseCPU(AVX512_16bit::kName, AVX512_16bit::kName, AVX2_16bit::kName, SSE2_16bit::kName, SSE2_16bit::kName, Unsupported_16bit::kName);
@@ -24,6 +26,8 @@ void (*Int8::PrepareB)(const float *input, int8_t *output, float quant_mult, Ind
void (*Int8::PrepareBQuantizedTransposed)(const int8_t *input, int8_t *output, Index inner, Index B_untransposed_cols) = ChooseCPU(AVX512_8bit::PrepareBQuantizedTransposed, AVX512_8bit::PrepareBQuantizedTransposed, AVX2_8bit::PrepareBQuantizedTransposed, SSSE3_8bit::PrepareBQuantizedTransposed, Unsupported_8bit::PrepareBQuantizedTransposed, Unsupported_8bit::PrepareBQuantizedTransposed);
+void (*Int8::PrepareBTransposed)(const float *input, int8_t *output, float quant_mult, Index inner, Index B_untransposed_cols) = ChooseCPU(AVX512_8bit::PrepareBTransposed, AVX512_8bit::PrepareBTransposed, AVX2_8bit::PrepareBTransposed, SSSE3_8bit::PrepareBTransposed, Unsupported_8bit::PrepareBTransposed, Unsupported_8bit::PrepareBTransposed);
+
void (*Int8::SelectColumnsB)(const int8_t *input, int8_t *output, Index rows, const Index *cols_begin, const Index *cols_end) = ChooseCPU(AVX512VNNI_8bit::SelectColumnsB, AVX512_8bit::SelectColumnsB, AVX2_8bit::SelectColumnsB, SSSE3_8bit::SelectColumnsB, Unsupported_8bit::SelectColumnsB, Unsupported_8bit::SelectColumnsB);
const char *const Int8::kName = ChooseCPU(AVX512VNNI_8bit::kName, AVX512_8bit::kName, AVX2_8bit::kName, SSSE3_8bit::kName, Unsupported_8bit::kName, Unsupported_8bit::kName);
diff --git a/intgemm.h b/intgemm.h
index b67ceda..8a63fb8 100644
--- a/intgemm.h
+++ b/intgemm.h
@@ -66,11 +66,12 @@ struct Unsupported_16bit {
static void PrepareB(const float *, int16_t *, float, Index, Index) {
throw UnsupportedCPU();
}
-
static void PrepareBQuantizedTransposed(const int16_t *, int16_t *, Index, Index) {
throw UnsupportedCPU();
}
-
+ static void PrepareBTransposed(const float *, int16_t *, float, Index, Index) {
+ throw UnsupportedCPU();
+ }
static void SelectColumnsB(const int16_t *, int16_t *, Index, const Index *, const Index *) {
throw UnsupportedCPU();
}
@@ -94,6 +95,9 @@ struct Unsupported_8bit {
static void PrepareBQuantizedTransposed(const int8_t *, int8_t *, Index, Index) {
throw UnsupportedCPU();
}
+ static void PrepareBTransposed(const float *, int8_t *, float, Index, Index) {
+ throw UnsupportedCPU();
+ }
static void PrepareB(const float *, int8_t *, float, Index, Index) {
throw UnsupportedCPU();
}
@@ -238,6 +242,11 @@ struct Int16 {
// CPU-independent fashion.
static void (*PrepareBQuantizedTransposed)(const int16_t *input, int16_t *output, Index inner, Index B_untransposed_cols);
+ // Convert from a B that was already transposed (routine not provided) to
+ // the CPU-dependent format used for Multiply. This is useful for storing
+ // a quantized model on disk then in a CPU-independent fashion.
+ static void (*PrepareBTransposed)(const float *input, int16_t *output, float quant_mul, Index inner, Index B_untransposed_cols);
+
// Select columns from a prepared B matrix. The number of selected columns must be a multiple of 8.
static void (*SelectColumnsB)(const int16_t *input, int16_t *output, Index rows, const Index *cols_begin, const Index *cols_end);
@@ -299,6 +308,11 @@ struct Int8 {
// CPU-independent fashion.
static void (*PrepareBQuantizedTransposed)(const int8_t *input, int8_t *output, Index inner, Index B_untransposed_cols);
+ // Convert from a B that was already transposed (routine not provided) to
+ // the CPU-dependent format used for Multiply. This is useful for storing
+ // a quantized model on disk then in a CPU-independent fashion.
+ static void (*PrepareBTransposed)(const float *input, int8_t *output, float quant_mul, Index inner, Index B_untransposed_cols);
+
// Select columns from a prepared B matrix. The number of selected columns must be a multiple of 8.
static void (*SelectColumnsB)(const int8_t *input, int8_t *output, Index rows, const Index *cols_begin, const Index *cols_end);