Skip to content

Commit

Permalink
[RELAY, TOPI] Deformable 2d convolution (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinx13 authored Jan 18, 2019
1 parent 2514df2 commit 7b2ed30
Show file tree
Hide file tree
Showing 18 changed files with 1,515 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "dlpack"]
path = 3rdparty/dlpack
url = https:/dmlc/dlpack
[submodule "3rdparty/mshadow"]
path = 3rdparty/mshadow
url = [email protected]:dmlc/mshadow.git
1 change: 1 addition & 0 deletions 3rdparty/mshadow
Submodule mshadow added at a8c650
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ include_directories("include")
include_directories("3rdparty/dlpack/include")
include_directories("3rdparty/dmlc-core/include")
include_directories("3rdparty/compiler-rt")
include_directories("3rdparty/mshadow")

# initial variables
set(TVM_LINKER_LIBS "")
Expand Down Expand Up @@ -189,8 +190,9 @@ include(cmake/modules/contrib/BLAS.cmake)
include(cmake/modules/contrib/Random.cmake)
include(cmake/modules/contrib/Sort.cmake)
include(cmake/modules/contrib/NNPack.cmake)
include(cmake/modules/contrib/MXNet.cmake)

add_library(tvm SHARED ${COMPILER_SRCS} ${RUNTIME_SRCS})
cuda_add_library(tvm SHARED ${COMPILER_SRCS} ${RUNTIME_SRCS})
add_library(tvm_topi SHARED ${TOPI_SRCS})
add_library(tvm_runtime SHARED ${RUNTIME_SRCS})
if(NOT USE_SGX STREQUAL "OFF")
Expand Down
3 changes: 3 additions & 0 deletions cmake/modules/contrib/MXNet.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
message(STATUS "Build with contrib.mxnet")
file(GLOB MXNET_CONTRIB_SRC "src/contrib/mxnet/*.cc" "src/contrib/mxnet/*.cu")
list(APPEND COMPILER_SRCS ${MXNET_CONTRIB_SRC})
15 changes: 15 additions & 0 deletions python/tvm/relay/frontend/mxnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,20 @@ def _mx_multibox_detection(inputs, attrs):
return _op.vision.nms(ret[0], ret[1], **new_attrs1)


def _mx_deformable_convolution(inputs, attrs):
new_attrs = {}
assert attrs.get_bool("no_bias")
new_attrs["kernel_size"] = attrs.get_int_tuple("kernel")
new_attrs["strides"] = attrs.get_int_tuple("stride")
new_attrs["dilation"] = attrs.get_int_tuple("dilate")
new_attrs["padding"] = attrs.get_int_tuple("pad")
new_attrs["channels"] = attrs.get_int("num_filter")
new_attrs["num_deformable_group"] = attrs.get_int("num_deformable_group", 1)
new_attrs["num_group"] = attrs.get_int("num_group", 1)
new_attrs["layout"] = attrs.get_str("layout", "NCHW")
return _op.nn.contrib_deformable_conv2d(inputs[0], inputs[1], inputs[2], **new_attrs)


# Note: due to attribute conversion constraint
# ops in the identity set must be attribute free
_identity_list = [
Expand Down Expand Up @@ -357,6 +371,7 @@ def _mx_multibox_detection(inputs, attrs):
# vision
"_contrib_MultiBoxPrior" : _mx_multibox_prior,
"_contrib_MultiBoxDetection" : _mx_multibox_detection,
"_contrib_DeformableConvolution": _mx_deformable_convolution,
# List of missing operators that are present in NNVMv1
# TODO(tvm-tvm): support all operators.
#
Expand Down
7 changes: 7 additions & 0 deletions python/tvm/relay/op/nn/nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,3 +858,10 @@ def contrib_conv2d_winograd_weight_transform(weight,
The computed result.
"""
return _make.contrib_conv2d_winograd_weight_transform(weight, tile_size)


def contrib_deformable_conv2d(data, offset, weight, strides, padding, dilation, channels,
kernel_size, num_deformable_group, num_group, layout):
return _make.contrib_deformable_conv2d(data, offset, weight, strides, padding, dilation,
channels, kernel_size, num_deformable_group, num_group,
layout)
Loading

0 comments on commit 7b2ed30

Please sign in to comment.