Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] add new operator LU factorization #1019

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/design_docs/sgetrf/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/23.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/25.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/26.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/design_docs/sgetrf/9.png
664 changes: 664 additions & 0 deletions docs/design_docs/sgetrf/sgetrf.md

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions docs/user_guide/9_operators/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -793,3 +793,10 @@ mluOpLgamma

- ``x`` 为输入张量。

.. Sgetrf2::
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.. Sgetrf2::这个是多写了?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.. Sgetrf2::>>>.. _sgetrf2:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个新增内容在手册的更新历史章节也补充下哈

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个能具体解释一下吗


mluOpSgetrf2
---------------
执行 LU 分解,将一个矩阵分解为一个下三角矩阵(L)和一个上三角矩阵(U),参数``mode``用来指定是否进行选主元操作。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

参数mode用来》》参数 mode 用来

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是什么意思?


ArtIntAI marked this conversation as resolved.
Show resolved Hide resolved
该算子包含7个输入:handle 为操作句柄,x_desc 与 x 分别描述并提供输入矩阵的信息;两个输出:y_desc 与 y 分别描述并存储输出矩阵的信息;此外,还包含一个参数 mode,用于指定是否进行选主元,值为0表示选择非主元模式,ipiv表示置换矩阵,以及一个 workspace 用于临时存储计算过程中的数据。
shunshen93 marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有公式的话,需要补充下公式。

Suggested change
该算子包含7个输入:handle 为操作句柄,x_desc 与 x 分别描述并提供输入矩阵的信息;两个输出:y_desc 与 y 分别描述并存储输出矩阵的信息;此外,还包含一个参数 mode,用于指定是否进行选主元,值为0表示选择非主元模式,ipiv表示置换矩阵,以及一个 workspace 用于临时存储计算过程中的数据。
该算子包含7个输入:其中,``handle`` 为操作句柄,``x_desc````x`` 分别描述并提供输入矩阵的信息;两个输出:``y_desc````y`` 分别描述并存储输出矩阵的信息;此外,还包含一个参数 ``mode`` 用于指定是否进行选主元操作,值为0时,表示选择非主元模式,``ipiv`` 表示置换矩阵,以及 ``workspace`` 用于临时存储计算过程中的数据。

》》7个输入中提到了三个(handle,x_desc和x)?mode、ipiv和workspace也是输入吗?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

61 changes: 61 additions & 0 deletions kernels/sgetrf2/mycnrtMemcpy2D_union1.mlu
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*************************************************************************
* Copyright (C) [2022] by Cambricon, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*************************************************************************/
#include "sgetrf2.h"
#include "sgetrf2_utils.h"
#include "core/logging.h"
#include "kernels/debug.h"
#include "kernels/kernel.h"

__mlu_entry__ void MLUKernelMyCnrtMemcpy2D(int batch, int m, int n, float *dA,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MLUKernelMyCnrtMemcpy2D建议去掉名字中的my,其他出现的类似的也删除my吧

int ldda, int stride_a, float *dB,
int lddb, int stride_b, int mode) {
int id, batch_id, tx, taskdim;

if (batch > 1) {
id = taskId;
batch_id = id / 4;
if (batch_id >= batch) return;
tx = taskId % 4;
dA += batch_id * stride_a;
dB += batch_id * stride_b;
taskdim = TaskUnion1;
} else {
id = taskId;
batch_id = 0;
taskdim = taskDim;
tx = taskId;
}
if (tx == 0)
__memcpy(dB, dA, n * sizeof(float), GDRAM2GDRAM, lddb * sizeof(float),
ldda * sizeof(float), m - 1);
}

mluOpStatus_t MLUOP_WIN_API KernelMyCnrtMemcpy2D(
cnrtDim3_t k_dim, cnrtFunctionType_t k_type, cnrtQueue_t queue,
mluOpDataType_t d_type, int batch, int m, int n, float *dA, int ldda,
int stride_a, float *dB, int lddb, int stride_b, int mode) {
KERNEL_CHECK(MLUKernelMyCnrtMemcpy2D<<<k_dim, k_type, queue>>>(
batch, m, n, dA, ldda, stride_a, dB, lddb, stride_b, mode));

return MLUOP_STATUS_SUCCESS;
}
Loading
Loading