Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
87ff58f7
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
404
Star
4705
Fork
582
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MegEngine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
87ff58f7
编写于
1月 19, 2021
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(megdnn): add algo for matmul/batchedmatrixmul of naive and opencl
GitOrigin-RevId: 2409b6ba164b40158da87e905aa53a1b1722a1c2
上级
169fa53d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
90 addition
and
17 deletion
+90
-17
dnn/src/naive/batched_matrix_mul/opr_impl.cpp
dnn/src/naive/batched_matrix_mul/opr_impl.cpp
+18
-3
dnn/src/naive/batched_matrix_mul/opr_impl.h
dnn/src/naive/batched_matrix_mul/opr_impl.h
+4
-7
dnn/src/naive/handle.cpp
dnn/src/naive/handle.cpp
+3
-0
dnn/src/naive/handle.h
dnn/src/naive/handle.h
+12
-0
dnn/src/naive/matrix_mul/algorithms.h
dnn/src/naive/matrix_mul/algorithms.h
+35
-0
dnn/src/naive/matrix_mul/opr_impl.cpp
dnn/src/naive/matrix_mul/opr_impl.cpp
+14
-0
dnn/src/naive/matrix_mul/opr_impl.h
dnn/src/naive/matrix_mul/opr_impl.h
+4
-7
未找到文件。
dnn/src/naive/batched_matrix_mul/opr_impl.cpp
浏览文件 @
87ff58f7
...
...
@@ -64,9 +64,24 @@ void BatchedMatrixMulForwardImpl::exec(_megdnn_tensor_in A,
}
}
// namespace naive
}
// namespace megdnn
std
::
vector
<
BatchedMatrixMulForward
::
Algorithm
*>
BatchedMatrixMulForwardImpl
::
get_all_algorithms
(
const
TensorLayout
&
/*A*/
,
const
TensorLayout
&
/*B*/
,
const
TensorLayout
&
/*C*/
)
{
return
{
static_cast
<
HandleImpl
*>
(
handle
())
->
default_batched_matmul_fwd_algo
()};
}
// vim: syntax=cpp.doxygen
BatchedMatrixMulForward
::
Algorithm
*
BatchedMatrixMulForwardImpl
::
get_algorithm_heuristic
(
const
TensorLayout
&
/*A*/
,
const
TensorLayout
&
/*B*/
,
const
TensorLayout
&
/*C*/
,
size_t
/*workspace_limit_in_bytes*/
,
bool
/* reproducible */
)
{
return
static_cast
<
HandleImpl
*>
(
handle
())
->
default_batched_matmul_fwd_algo
();
}
}
// namespace naive
}
// namespace megdnn
// vim: syntax=cpp.doxygen
dnn/src/naive/batched_matrix_mul/opr_impl.h
浏览文件 @
87ff58f7
...
...
@@ -6,7 +6,8 @@
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied.
*/
#pragma once
#include "megdnn/oprs.h"
...
...
@@ -25,17 +26,13 @@ public:
std
::
vector
<
Algorithm
*>
get_all_algorithms
(
const
TensorLayout
&
/*A*/
,
const
TensorLayout
&
/*B*/
,
const
TensorLayout
&
/*C*/
)
override
{
return
{};
}
const
TensorLayout
&
/*C*/
)
override
;
Algorithm
*
get_algorithm_heuristic
(
const
TensorLayout
&
/*A*/
,
const
TensorLayout
&
/*B*/
,
const
TensorLayout
&
/*C*/
,
size_t
/*workspace_limit_in_bytes*/
,
bool
/* reproducible */
)
override
{
return
nullptr
;
}
bool
/* reproducible */
)
override
;
const
char
*
get_algorithm_set_name
()
const
override
{
return
"DEFAULT"
;
}
...
...
dnn/src/naive/handle.cpp
浏览文件 @
87ff58f7
...
...
@@ -106,6 +106,9 @@ DefaultLocalShareBackwardDataAlgorithm
DefaultLocalShareBackwardFilterAlgorithm
HandleImpl
::
m_default_local_share_bwd_filter_algo
;
DefaultMatrixMulAlgorithm
HandleImpl
::
m_default_matmul_fwd_algo
;
DefaultBatchedMatrixMulAlgorithm
HandleImpl
::
m_default_batched_matmul_fwd_algo
;
HandleImpl
::
HandleImpl
(
megcoreComputingHandle_t
computing_handle
,
HandleType
type
)
:
HandleImplHelper
(
computing_handle
,
type
),
...
...
dnn/src/naive/handle.h
浏览文件 @
87ff58f7
...
...
@@ -13,6 +13,7 @@
#include "src/common/handle_impl.h"
#include "src/naive/convolution/algorithms.h"
#include "src/naive/matrix_mul/algorithms.h"
#include "src/naive/local_share/algorithms.h"
#include "src/naive/convolution3d/algorithms.h"
...
...
@@ -46,6 +47,9 @@ class HandleImpl : public HandleImplHelper {
static
DefaultLocalShareBackwardFilterAlgorithm
m_default_local_share_bwd_filter_algo
;
static
DefaultMatrixMulAlgorithm
m_default_matmul_fwd_algo
;
static
DefaultBatchedMatrixMulAlgorithm
m_default_batched_matmul_fwd_algo
;
//! move KernFunc to alloc_kern()->func, destruct func, and call dispatch
template
<
typename
T
>
void
move_kern_func_to_new_kern_and_dispatch
(
T
&
func
)
{
...
...
@@ -109,6 +113,14 @@ public:
return
&
m_default_local_share_bwd_filter_algo
;
}
MatrixMulForward
::
Algorithm
*
default_matmul_fwd_algo
()
{
return
&
m_default_matmul_fwd_algo
;
}
BatchedMatrixMulForward
::
Algorithm
*
default_batched_matmul_fwd_algo
()
{
return
&
m_default_batched_matmul_fwd_algo
;
}
Relayout
*
relayout_opr
()
override
{
return
get_helper_opr
<
Relayout
,
2
>
(
this
);
}
...
...
dnn/src/naive/matrix_mul/algorithms.h
0 → 100644
浏览文件 @
87ff58f7
/**
* \file dnn/src/naive/matrix_mul/algorithms.h
* MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
*
* Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied.
*/
#pragma once
#include "megdnn/oprs/linalg.h"
namespace
megdnn
{
namespace
naive
{
class
DefaultMatrixMulAlgorithm
final
:
public
megdnn
::
MatrixMulForward
::
Algorithm
{
bool
is_reproducible
()
const
override
{
return
true
;
}
const
char
*
name
()
const
override
{
return
"DEFAULT"
;
}
uint32_t
type
()
const
override
{
return
0
;
}
};
class
DefaultBatchedMatrixMulAlgorithm
final
:
public
megdnn
::
BatchedMatrixMulForward
::
Algorithm
{
bool
is_reproducible
()
const
override
{
return
true
;
}
const
char
*
name
()
const
override
{
return
"DEFAULT"
;
}
uint32_t
type
()
const
override
{
return
0
;
}
};
}
// namespace naive
}
// namespace megdnn
// vim: syntax=cpp.doxygen
dnn/src/naive/matrix_mul/opr_impl.cpp
浏览文件 @
87ff58f7
...
...
@@ -81,6 +81,20 @@ void MatrixMulForwardImpl::exec(_megdnn_tensor_in A, _megdnn_tensor_in B,
MIDOUT_END
();
}
std
::
vector
<
MatrixMulForward
::
Algorithm
*>
MatrixMulForwardImpl
::
get_all_algorithms
(
const
TensorLayout
&
/*A*/
,
const
TensorLayout
&
/*B*/
,
const
TensorLayout
&
/*C*/
)
{
return
{
static_cast
<
HandleImpl
*>
(
handle
())
->
default_matmul_fwd_algo
()};
}
MatrixMulForward
::
Algorithm
*
MatrixMulForwardImpl
::
get_algorithm_heuristic
(
const
TensorLayout
&
/*A*/
,
const
TensorLayout
&
/*B*/
,
const
TensorLayout
&
/*C*/
,
size_t
/*workspace_limit_in_bytes*/
,
bool
/* reproducible */
)
{
return
static_cast
<
HandleImpl
*>
(
handle
())
->
default_matmul_fwd_algo
();
}
}
// namespace naive
}
// namespace megdnn
...
...
dnn/src/naive/matrix_mul/opr_impl.h
浏览文件 @
87ff58f7
...
...
@@ -6,7 +6,8 @@
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied.
*/
#pragma once
#include "megdnn/oprs.h"
...
...
@@ -26,17 +27,13 @@ public:
std
::
vector
<
Algorithm
*>
get_all_algorithms
(
const
TensorLayout
&
/*A*/
,
const
TensorLayout
&
/*B*/
,
const
TensorLayout
&
/*C*/
)
override
{
return
{};
}
const
TensorLayout
&
/*C*/
)
override
;
Algorithm
*
get_algorithm_heuristic
(
const
TensorLayout
&
/*A*/
,
const
TensorLayout
&
/*B*/
,
const
TensorLayout
&
/*C*/
,
size_t
/*workspace_limit_in_bytes*/
,
bool
/* reproducible */
)
override
{
return
nullptr
;
}
bool
/* reproducible */
)
override
;
const
char
*
get_algorithm_set_name
()
const
override
{
return
"DEFAULT"
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录