【问题标题】:Simple cblas gemm code but strange result简单的 cblas gemm 代码但奇怪的结果
【发布时间】:2018-11-27 06:03:58
【问题描述】:

以下是c代码

const int M = 4;
const int N = 1;
const int K = 2;
const int LDA = M;
const int LDB = K;
const int LDC = M;
float input_data[2]{1, 1};
float weight_data[8]{1.1, 2.01, 3.001, 4.0001, 5.1, 6.01, 7.001, 8.0001};
float output_data[4];

cblas_sgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, M, N, K, 1, weight_data, LDA, input_data, LDB, 0, output_data, LDC);

预期结果是 {6.2, 8.02, 10.002, 12.0002}。相反,我得到了 {4.101, 6.0101, 12.101, 14.0101}。

代码很简单。文档查了很多遍,不知道哪里做错了。

你能帮忙指出问题吗?提前致谢!


更新:

我试过 2*2 和 3*2 weight_data,两个结果都是正确的。但是 4*2 weight_data 会产生错误的结果

【问题讨论】:

    标签: blas openblas cblas


    【解决方案1】:

    原来是 OpenBLAS 的一个错误。我从没想过openblas可能有错误。我花了两天时间。

    https://github.com/xianyi/OpenBLAS/issues/1870

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-08
      • 2011-10-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多