Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
59a8d099
Commit
59a8d099
authored
Jun 25, 2018
by
nhynes
Committed by
Tianqi Chen
Jun 25, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NNVM][TOPI] Add FTVMCompute for matmul (#1239)
parent
d29b1c9e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
4 deletions
+20
-4
nnvm/python/nnvm/top/nn.py
+3
-0
nnvm/src/top/tensor/matrix_op.cc
+13
-0
topi/include/topi/nn.h
+3
-3
topi/include/topi/tags.h
+1
-1
No files found.
nnvm/python/nnvm/top/nn.py
View file @
59a8d099
...
@@ -73,6 +73,9 @@ def schedule_dense(_, outs, target):
...
@@ -73,6 +73,9 @@ def schedule_dense(_, outs, target):
reg
.
register_pattern
(
"dense"
,
OpPattern
.
OUT_ELEMWISE_FUSABLE
)
reg
.
register_pattern
(
"dense"
,
OpPattern
.
OUT_ELEMWISE_FUSABLE
)
#matmul
reg
.
register_pattern
(
"matmul"
,
OpPattern
.
OUT_ELEMWISE_FUSABLE
)
reg
.
register_schedule
(
"matmul"
,
_fschedule_injective
)
# conv2d
# conv2d
@reg.register_compute
(
"conv2d"
)
@reg.register_compute
(
"conv2d"
)
...
...
nnvm/src/top/tensor/matrix_op.cc
View file @
59a8d099
...
@@ -3,9 +3,11 @@
...
@@ -3,9 +3,11 @@
* \file matrix_op.cc
* \file matrix_op.cc
* \brief Matrix operators
* \brief Matrix operators
*/
*/
#include <topi/nn.h>
#include <nnvm/op.h>
#include <nnvm/op.h>
#include <nnvm/node.h>
#include <nnvm/node.h>
#include <nnvm/op_attr_types.h>
#include <nnvm/op_attr_types.h>
#include <nnvm/compiler/op_attr_types.h>
#include <nnvm/top/tensor.h>
#include <nnvm/top/tensor.h>
#include "../op_common.h"
#include "../op_common.h"
#include "../elemwise_op_common.h"
#include "../elemwise_op_common.h"
...
@@ -13,6 +15,8 @@
...
@@ -13,6 +15,8 @@
namespace
nnvm
{
namespace
nnvm
{
namespace
top
{
namespace
top
{
using
namespace
nnvm
::
compiler
;
DMLC_REGISTER_PARAMETER
(
MatMulParam
);
DMLC_REGISTER_PARAMETER
(
MatMulParam
);
inline
bool
DotShape
(
const
nnvm
::
NodeAttrs
&
attrs
,
inline
bool
DotShape
(
const
nnvm
::
NodeAttrs
&
attrs
,
...
@@ -93,6 +97,15 @@ NNVM_REGISTER_OP(matmul)
...
@@ -93,6 +97,15 @@ NNVM_REGISTER_OP(matmul)
.
set_attr
<
FInferShape
>
(
"FInferShape"
,
DotShape
)
.
set_attr
<
FInferShape
>
(
"FInferShape"
,
DotShape
)
.
set_attr
<
FInferType
>
(
"FInferType"
,
ElemwiseType
<
2
,
1
>
)
.
set_attr
<
FInferType
>
(
"FInferType"
,
ElemwiseType
<
2
,
1
>
)
.
set_attr
<
FCorrectLayout
>
(
"FCorrectLayout"
,
DotCorrectLayout
)
.
set_attr
<
FCorrectLayout
>
(
"FCorrectLayout"
,
DotCorrectLayout
)
.
set_attr
<
FTVMCompute
>
(
"FTVMCompute"
,
[](
const
NodeAttrs
&
attrs
,
const
Array
<
Tensor
>&
inputs
,
const
Array
<
Tensor
>&
out_info
)
{
const
MatMulParam
&
param
=
nnvm
::
get
<
MatMulParam
>
(
attrs
.
parsed
);
return
Array
<
Tensor
>
{
topi
::
matmul
(
inputs
[
0
],
inputs
[
1
],
param
.
transpose_a
,
param
.
transpose_b
)
};
})
.
set_attr
<
FGradient
>
(
.
set_attr
<
FGradient
>
(
"FGradient"
,
[](
const
NodePtr
&
n
,
"FGradient"
,
[](
const
NodePtr
&
n
,
const
std
::
vector
<
NodeEntry
>&
ograds
)
{
const
std
::
vector
<
NodeEntry
>&
ograds
)
{
...
...
topi/include/topi/nn.h
View file @
59a8d099
...
@@ -214,14 +214,14 @@ inline tvm::Tensor pad(const tvm::Tensor& t,
...
@@ -214,14 +214,14 @@ inline tvm::Tensor pad(const tvm::Tensor& t,
* \param name The name of the operation
* \param name The name of the operation
* \param tag The tag to mark the operation
* \param tag The tag to mark the operation
*
*
* \return A Tensor whose op member is the matmul
t
operation
* \return A Tensor whose op member is the matmul operation
*/
*/
inline
tvm
::
Tensor
matmul
t
(
const
tvm
::
Tensor
&
A
,
inline
tvm
::
Tensor
matmul
(
const
tvm
::
Tensor
&
A
,
const
tvm
::
Tensor
&
B
,
const
tvm
::
Tensor
&
B
,
bool
trans_a
=
false
,
bool
trans_a
=
false
,
bool
trans_b
=
false
,
bool
trans_b
=
false
,
std
::
string
name
=
"tensor"
,
std
::
string
name
=
"tensor"
,
std
::
string
tag
=
kMatMul
t
)
{
std
::
string
tag
=
kMatMul
)
{
tvm
::
Array
<
tvm
::
Expr
>
output_shape
{
A
->
shape
[
trans_a
?
1
:
0
],
tvm
::
Array
<
tvm
::
Expr
>
output_shape
{
A
->
shape
[
trans_a
?
1
:
0
],
B
->
shape
[
trans_b
?
0
:
1
]};
B
->
shape
[
trans_b
?
0
:
1
]};
auto
k
=
tvm
::
reduce_axis
(
tvm
::
Range
{
0
,
A
->
shape
[
trans_a
?
0
:
1
]},
"k"
);
auto
k
=
tvm
::
reduce_axis
(
tvm
::
Range
{
0
,
A
->
shape
[
trans_a
?
0
:
1
]},
"k"
);
...
...
topi/include/topi/tags.h
View file @
59a8d099
...
@@ -15,7 +15,7 @@ constexpr auto kInjective = "injective";
...
@@ -15,7 +15,7 @@ constexpr auto kInjective = "injective";
constexpr
auto
kCommReduce
=
"comm_reduce"
;
constexpr
auto
kCommReduce
=
"comm_reduce"
;
constexpr
auto
kCommReduceIdx
=
"comm_reduce_idx"
;
constexpr
auto
kCommReduceIdx
=
"comm_reduce_idx"
;
constexpr
auto
kBroadcast
=
"broadcast"
;
constexpr
auto
kBroadcast
=
"broadcast"
;
constexpr
auto
kMatMul
t
=
"matmult
"
;
constexpr
auto
kMatMul
=
"matmul
"
;
constexpr
auto
kConv2dNCHW
=
"conv2d_nchw"
;
constexpr
auto
kConv2dNCHW
=
"conv2d_nchw"
;
constexpr
auto
kConv2dHWCN
=
"conv2d_hwcn"
;
constexpr
auto
kConv2dHWCN
=
"conv2d_hwcn"
;
constexpr
auto
kDepthwiseConv2dNCHW
=
"depthwise_conv2d_nchw"
;
constexpr
auto
kDepthwiseConv2dNCHW
=
"depthwise_conv2d_nchw"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment