提交 9890c29b 编写于 作者: L looop5

add macro in CMakeLists.txt to differ backend d and gpu, add modification statement

上级 1f184177
...@@ -98,6 +98,9 @@ add_definitions(-DDMLC_LOG_CUSTOMIZE=1) ...@@ -98,6 +98,9 @@ add_definitions(-DDMLC_LOG_CUSTOMIZE=1)
if(USE_AKG_LOG) if(USE_AKG_LOG)
add_definitions(-DUSE_AKG_LOG=1) add_definitions(-DUSE_AKG_LOG=1)
endif() endif()
if(NOT USE_CUDA)
add_definitions("-DBACKEND_D")
endif()
# Generic compilation options # Generic compilation options
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
......
...@@ -234,33 +234,32 @@ class HostDeviceSplitter : public IRMutator { ...@@ -234,33 +234,32 @@ class HostDeviceSplitter : public IRMutator {
} }
} }
const char* mode = getenv("RUNTIME_MODE"); #ifdef BACKEND_D
if (mode) { std::shared_ptr<LoweredFuncNode> na = std::make_shared<LoweredFuncNode>();
std::shared_ptr<LoweredFuncNode> na = std::make_shared<LoweredFuncNode>(); for (unsigned i = 0; i < (unsigned)args_real.size(); i++) {
for (unsigned i = 0; i < (unsigned)args_real.size(); i++) { bool match = false;
bool match = false; for (unsigned j = 0; j < (unsigned)n->args.size(); j++) {
for (unsigned j = 0; j < (unsigned)n->args.size(); j++) { if (strcmp(args_real[i].get()->name_hint.c_str(), n->args[j].get()->name_hint.c_str()) == 0) {
if (strcmp(args_real[i].get()->name_hint.c_str(), n->args[j].get()->name_hint.c_str()) == 0) { na->args.push_back(n->args[j]);
na->args.push_back(n->args[j]); match = true;
match = true; break;
break; } else {
} else { continue;
continue;
}
} }
}
if (!match) { if (!match) {
na->args.push_back(args_real[i]); na->args.push_back(args_real[i]);
// mark handle data type. // mark handle data type.
for (auto kv : handle_data_type_) { for (auto kv : handle_data_type_) {
if (strcmp(args_real[i].get()->name_hint.c_str(), kv.first->name_hint.c_str()) == 0) { if (strcmp(args_real[i].get()->name_hint.c_str(), kv.first->name_hint.c_str()) == 0) {
n->handle_data_type.Set(args_real[i], kv.second); n->handle_data_type.Set(args_real[i], kv.second);
}
} }
} }
} }
n->args = na->args;
} }
n->args = na->args;
#endif
LoweredFunc f_device(n); LoweredFunc f_device(n);
Array<Expr> call_args; Array<Expr> call_args;
......
diff -uprN tvm_orig/python/tvm/_ffi/base.py tvm/python/tvm/_ffi/base.py diff -Npur tvm_orig/python/tvm/_ffi/base.py tvm/python/tvm/_ffi/base.py
--- tvm_orig/python/tvm/_ffi/base.py 2020-04-13 20:18:09.519984547 +0800 --- tvm_orig/python/tvm/_ffi/base.py 2020-07-16 14:39:28.859033775 +0800
+++ tvm/python/tvm/_ffi/base.py 2020-04-13 20:14:21.510253128 +0800 +++ tvm/python/tvm/_ffi/base.py 2020-07-16 14:42:26.594223690 +0800
@@ -48,7 +48,18 @@ else: @@ -16,6 +16,11 @@
# under the License.
# coding: utf-8
# pylint: disable=invalid-name
+
+#
+# 2020.7.16 - Modify _load_lib function to find the correct library.
+#
+
"""Base library for TVM FFI."""
from __future__ import absolute_import
@@ -48,7 +53,18 @@ else:
def _load_lib(): def _load_lib():
"""Load libary by searching possible path.""" """Load libary by searching possible path."""
...@@ -21,10 +33,22 @@ diff -uprN tvm_orig/python/tvm/_ffi/base.py tvm/python/tvm/_ffi/base.py ...@@ -21,10 +33,22 @@ diff -uprN tvm_orig/python/tvm/_ffi/base.py tvm/python/tvm/_ffi/base.py
lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_GLOBAL) lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_GLOBAL)
# DMatrix functions # DMatrix functions
lib.TVMGetLastError.restype = ctypes.c_char_p lib.TVMGetLastError.restype = ctypes.c_char_p
diff -uprN tvm_orig/topi/python/topi/cpp/impl.py tvm/topi/python/topi/cpp/impl.py diff -Npur tvm_orig/topi/python/topi/cpp/impl.py tvm/topi/python/topi/cpp/impl.py
--- tvm_orig/topi/python/topi/cpp/impl.py 2020-04-13 20:18:09.535984509 +0800 --- tvm_orig/topi/python/topi/cpp/impl.py 2020-07-16 14:40:07.754722324 +0800
+++ tvm/topi/python/topi/cpp/impl.py 2020-04-13 20:16:41.784427200 +0800 +++ tvm/topi/python/topi/cpp/impl.py 2020-07-16 14:42:56.638225874 +0800
@@ -31,11 +31,18 @@ def _get_lib_names(): @@ -14,6 +14,11 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+
+#
+# 2020.7.16 - Modify _load_lib function to find the correct library.
+#
+
"""Load Lib for C++ TOPI ops and schedules"""
import sys
import os
@@ -31,11 +36,18 @@ def _get_lib_names():
def _load_lib(): def _load_lib():
"""Load libary by searching possible path.""" """Load libary by searching possible path."""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册