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

TestUtils.h « test - github.com/marian-nmt/FBGEMM.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d320ae259ddd1abe0b46d778109866e704bb7695 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 * Copyright (c) Facebook, Inc. and its affiliates.
 * All rights reserved.
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree.
 */
#pragma once
#include <cmath>
#include <vector>
#include "fbgemm/Fbgemm.h"

namespace fbgemm {

static std::vector<matrix_op_t> transposeVals = { matrix_op_t::NoTranspose,
                                    matrix_op_t::Transpose };

static std::vector<QuantizationGranularity> qGranularityVals = {
      QuantizationGranularity::TENSOR,
      QuantizationGranularity::GROUP,
      QuantizationGranularity::OUT_CHANNEL };

/*
 * @brief Check and validate the buffers for reference and FBGEMM result.
 */
template <typename T>
int compare_validate_buffers(
    const T* ref,
    const T* test,
    int m,
    int n,
    int ld,
    T atol);

/*
 * @brief Check if all entries are zero or not.
 * If any entry is non-zero, return True;
 * otherwise, return False.
 */
template <typename T>
bool check_all_zero_entries(const T* test, int m, int n);

/*
 * @brief In-place transposition for nxk matrix ref.
 * @params n number of rows in input (number of columns in output)
 * @params k number of columns in input (number of rows in output)
 */
template <typename T>
void transpose_matrix(T* ref, int n, int k);

/*
 * @brief Out-of-place transposition for M*N matrix ref.
 * @params M number of rows in input
 * @params K number of columns in input
 */
template <typename T>
void transpose_matrix(
    int M,
    int N,
    const T* src,
    int ld_src,
    T* dst,
    int ld_dst);

} // namespace fbgemm