Skip to content

Commit fd26d84

Browse files
committed
update changes
1 parent 03dad90 commit fd26d84

9 files changed

Lines changed: 142 additions & 16 deletions

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
### How to Install:
66

77
```sh
8-
python3 -m pip install https://github.com/microsoft/antares/releases/download/v0.3.0/antares-0.3.0-py3-none-linux_x86_64.whl
8+
python3 -m pip install antares
99
```
1010

1111
### Quick Test:
@@ -20,6 +20,9 @@ BACKEND=c-scpu antares
2020
# Quickly generate a multi-threaded CPU code:
2121
BACKEND=c-mcpu antares
2222

23+
# Search an efficient multi-threaded CPU code:
24+
STEP=100 BACKEND=c-mcpu antares
25+
2326
# Quickly generate a SHADER code for Windows 10/11's DirectX12:
2427
BACKEND=c-hlsl_win64 antares
2528

antares/antares_compiler.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import random
66
import hashlib
77
import traceback
8-
import numpy as np
98
import math
109
import re
1110
import json
@@ -324,14 +323,14 @@ def compute_mem_ratio(tpr):
324323
global_arg_props = get_global_arg_props()
325324
access_bytes = 0
326325
for buf in global_arg_props['_in']:
327-
access_bytes += np.product(buf['shape']) * get_type_size(buf['dtype'])
326+
access_bytes += product(buf['shape']) * get_type_size(buf['dtype'])
328327
for buf in global_arg_props['_out']:
329-
access_bytes += np.product(buf['shape']) * get_type_size(buf['dtype'])
328+
access_bytes += product(buf['shape']) * get_type_size(buf['dtype'])
330329

331330
access_bytes = int(access_bytes)
332331
if access_bytes <= 0:
333332
return -1
334-
ratio = np.ceil(access_bytes * 1e-7 / tpr / device_properties().mem_bandwith)
333+
ratio = math.ceil(access_bytes * 1e-7 / tpr / device_properties().mem_bandwith)
335334
return min(int(ratio), 100)
336335

337336
def run_config_entity(target_source, config_str, dir_sid, expected_timecost='inf', dev_id=0):

antares/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44
import os
55
import subprocess
66
import math
7-
import numpy as np
7+
from functools import reduce
88

99
class Mock(object):
1010
pass
1111

1212
backend = os.environ['BACKEND']
1313
AntaresGlobal = Mock()
1414

15+
def product(arrlist):
16+
return reduce((lambda x, y: x * y), arrlist)
17+
1518
def wait_for(func, timeout=None, args=[]):
1619
if not timeout:
1720
return func(*args)

backends/c-mcpu/schedule/standard/default.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from tvm import te
55
import numpy as np
6-
import psutil
76

87
def schedule(attrs):
98
cfg, s = attrs.auto_config, attrs.scheduler

docker/Dockerfile.c-base

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ RUN bash -c 'rm -rf ~/.local/antares/3rdparty/tvm/build/{CMake*,Makefile,cmake_i
2121
RUN bash -c 'rm -rf ~/.local/antares/3rdparty/tvm/{src,include,golang,tests,3rdparty,device-stub,apps,.??*}'
2222
RUN echo '' > ~/.local/antares/3rdparty/tvm/python/tvm/relay/__init__.py
2323

24-
ENV ANTARES_VERSION 0.3.0_0
24+
ENV ANTARES_VERSION 0.3.1
2525

2626
RUN cd ~ && git clone https://github.com/microsoft/antares --single-branch --depth 1 antares_core && mv ~/.local/antares/3rdparty antares_core
2727
RUN cd ~ && sed -i "s/@VERSION@/${ANTARES_VERSION}/g" /antares/engine/dist-info/METADATA && cp -r /antares/engine/dist-info ~/antares-${ANTARES_VERSION}.dist-info
28-
RUN cd ~ && rm -rf antares_core/.??* && zip -r /antares-${ANTARES_VERSION}-py3-none-linux_x86_64.whl antares* >/dev/null
28+
RUN cd ~ && rm -rf antares_core/.??* && zip -r /antares-${ANTARES_VERSION}-py3-none-manylinux1_x86_64.whl antares* >/dev/null

engine/device-stub/tvm_extra.patch

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
diff --git a/src/runtime/dso_library.cc b/src/runtime/dso_library.cc
2+
index 81eb30ee1..785fb48ac 100644
3+
--- a/src/runtime/dso_library.cc
4+
+++ b/src/runtime/dso_library.cc
5+
@@ -115,15 +115,16 @@ void DSOLibrary::Unload() {
6+
#else
7+
8+
void DSOLibrary::Load(const std::string& name) {
9+
+ abort(); /*
10+
lib_handle_ = dlopen(name.c_str(), RTLD_LAZY | RTLD_LOCAL);
11+
ICHECK(lib_handle_ != nullptr) << "Failed to load dynamic shared library " << name << " "
12+
- << dlerror();
13+
+ << dlerror(); */
14+
}
15+
16+
-void* DSOLibrary::GetSymbol_(const char* name) { return dlsym(lib_handle_, name); }
17+
+void* DSOLibrary::GetSymbol_(const char* name) { abort(); /* return dlsym(lib_handle_, name); */ }
18+
19+
void DSOLibrary::Unload() {
20+
- dlclose(lib_handle_);
21+
+ abort(); // dlclose(lib_handle_);
22+
lib_handle_ = nullptr;
23+
}
24+
25+
diff --git a/CMakeLists.txt b/CMakeLists.txt
26+
index 7293abb60..d741ce2a2 100644
27+
--- a/CMakeLists.txt
28+
+++ b/CMakeLists.txt
29+
@@ -1,6 +1,10 @@
30+
cmake_minimum_required(VERSION 3.2)
31+
project(tvm C CXX)
32+
33+
+set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-static-libgcc -static-libstdc++")
34+
+set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-static-libgcc -static-libstdc++")
35+
+set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
36+
+
37+
# Utility functions
38+
include(cmake/utils/Utils.cmake)
39+
include(cmake/utils/FindCUDA.cmake)
40+
@@ -50,7 +54,7 @@ tvm_option(USE_FALLBACK_STL_MAP "Use TVM's POD compatible Map" OFF)
41+
tvm_option(USE_ETHOSN "Build with Arm Ethos-N" OFF)
42+
tvm_option(USE_CMSISNN "Build with Arm CMSIS-NN" OFF)
43+
tvm_option(INDEX_DEFAULT_I64 "Defaults the index datatype to int64" ON)
44+
-tvm_option(USE_LIBBACKTRACE "Build libbacktrace to supply linenumbers on stack traces" AUTO)
45+
+# tvm_option(USE_LIBBACKTRACE "Build libbacktrace to supply linenumbers on stack traces" AUTO)
46+
tvm_option(BUILD_STATIC_RUNTIME "Build static version of libtvm_runtime" OFF)
47+
tvm_option(USE_PAPI "Use Performance Application Programming Interface (PAPI) to read performance counters" OFF)
48+
tvm_option(USE_GTEST "Use GoogleTest for C++ sanity tests" AUTO)
49+
@@ -497,7 +501,7 @@ target_compile_definitions(tvm PUBLIC DMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logg
50+
target_compile_definitions(tvm_runtime PUBLIC DMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>)
51+
52+
# logging option for libbacktrace
53+
-include(cmake/modules/Logging.cmake)
54+
+# include(cmake/modules/Logging.cmake)
55+
56+
include(cmake/modules/contrib/PAPI.cmake)
57+
58+
diff --git a/src/runtime/threading_backend.cc b/src/runtime/threading_backend.cc
59+
index 5b3093ac8..ce0d33fa1 100644
60+
--- a/src/runtime/threading_backend.cc
61+
+++ b/src/runtime/threading_backend.cc
62+
@@ -127,7 +127,7 @@ class ThreadGroup::Impl {
63+
#if defined(__ANDROID__)
64+
sched_setaffinity(threads_[i].native_handle(), sizeof(cpu_set_t), &cpuset);
65+
#else
66+
- pthread_setaffinity_np(threads_[i].native_handle(), sizeof(cpu_set_t), &cpuset);
67+
+ abort(); // pthread_setaffinity_np(threads_[i].native_handle(), sizeof(cpu_set_t), &cpuset);
68+
#endif
69+
}
70+
if (exclude_worker0) { // main thread run task
71+
@@ -167,7 +167,7 @@ class ThreadGroup::Impl {
72+
#if defined(__ANDROID__)
73+
sched_setaffinity(pthread_self(), sizeof(cpu_set_t), &cpuset);
74+
#else
75+
- pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
76+
+ abort(); // pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
77+
#endif
78+
#endif
79+
}
80+
@@ -227,7 +227,7 @@ class ThreadGroup::Impl {
81+
82+
ThreadGroup::ThreadGroup(int num_workers, std::function<void(int)> worker_callback,
83+
bool exclude_worker0)
84+
- : impl_(new ThreadGroup::Impl(num_workers, worker_callback, exclude_worker0)) {}
85+
+ : impl_((abort(), nullptr) /* new ThreadGroup::Impl(num_workers, worker_callback, exclude_worker0) */) {}
86+
ThreadGroup::~ThreadGroup() { delete impl_; }
87+
void ThreadGroup::Join() { impl_->Join(); }
88+
89+
diff --git a/src/support/parallel_for.cc b/src/support/parallel_for.cc
90+
index e90967562..e55ed2b25 100644
91+
--- a/src/support/parallel_for.cc
92+
+++ b/src/support/parallel_for.cc
93+
@@ -49,6 +49,8 @@ std::vector<std::vector<int>> rr_partitioner(int begin, int end, int step, int n
94+
95+
void parallel_for(int begin, int end, const std::function<void(int)>& f, int step,
96+
const PartitionerFuncType partitioner) {
97+
+ abort();
98+
+#if 0
99+
static bool GLOBAL_PARALLEL_FOR_FLAG{false};
100+
static std::mutex M_GLOBAL_PARALLEL_FOR_FLAG;
101+
{
102+
@@ -91,10 +93,13 @@ void parallel_for(int begin, int end, const std::function<void(int)>& f, int ste
103+
} catch (const std::exception& e) {
104+
LOG(FATAL) << "Parallel_for error with " << e.what();
105+
}
106+
+#endif
107+
}
108+
109+
void parallel_for_dynamic(int begin, int end, int num_threads,
110+
const std::function<void(int thread_id, int task_id)>& f) {
111+
+ abort();
112+
+#if 0
113+
// Step 1. Sanity checks
114+
if (begin == end) {
115+
return;
116+
@@ -138,6 +143,7 @@ void parallel_for_dynamic(int begin, int end, int num_threads,
117+
} catch (const std::exception& e) {
118+
LOG(FATAL) << "RuntimeError: parallel_for_dynamic error with " << e.what();
119+
}
120+
+#endif
121+
}
122+
123+
} // namespace support

engine/dist-info/METADATA

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,8 @@ Keywords: antares dnn
88
Platform: UNKNOWN
99
Requires-Dist: wheel (>=0.26) ; python_version >= "3"
1010
Requires-Dist: tornado ; python_version >= "3"
11-
Requires-Dist: psutil ; python_version >= "3"
1211
Requires-Dist: numpy ; python_version >= "3"
1312
Requires-Dist: decorator ; python_version >= "3"
14-
Requires-Dist: attrs ; python_version >= "3"
15-
Requires-Dist: pytest ; python_version >= "3"
16-
Requires-Dist: typed_ast ; python_version >= "3"
17-
Requires-Dist: cloudpickle ; python_version >= "3"
1813

1914
Antares is an engine to automatically generate optimized kernels for multi-platform
2015

graph_evaluator/client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ def eval(kernel_path, **kwargs):
6767
return eval_client.eval(kernel_path, **kwargs)
6868

6969
is_wsl = 1 if (os.environ.get('IS_WSL', '0') == '1') else 0
70-
if is_wsl == os.system(f'file {evaluator_path} | grep "MS Windows" >/dev/null 2>&1'):
70+
with open(evaluator_path, 'rb') as fp:
71+
exec_magic = fp.read(2)
72+
73+
if is_wsl == 0 and exec_magic == b'MZ':
7174
print(f"Antares should run under WSL-1/2 for this backend({backend}), otherwise, evaluation would be skipped.")
7275
exit(1)
7376

lang/generic.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ def select_plan(plan_name):
150150
try:
151151
return select_plan(plan)
152152
except ModuleNotFoundError:
153-
setattr(AntaresGlobal, 'mode', 'antares')
153+
traceback.print_exc()
154+
# setattr(AntaresGlobal, 'mode', 'antares')
154155
return None
155156

156157

0 commit comments

Comments
 (0)