Skip to content

Commit 137def8

Browse files
authored
[TARGET] Move target_host usage to new target style. (apache#9497)
- Add deprecation warnings to functions with target_host parameters. - Update the build usage to new target style.
1 parent 6159b8e commit 137def8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+162
-77
lines changed

apps/android_camera/models/prepare_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def main(model_str, output_path):
9898
pass
9999
print("building...")
100100
with tvm.transform.PassContext(opt_level=3):
101-
graph, lib, params = relay.build(net, target, target_host=target_host, params=params)
101+
graph, lib, params = relay.build(net, tvm.target.Target(target, target_host), params=params)
102102
print("dumping lib...")
103103
lib.export_library(output_path_str + "/" + "deploy_lib_cpu.so", ndk.create_shared)
104104
print("dumping graph...")

apps/android_rpc/tests/android_rpc_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def test_rpc_module():
8686
s[B].bind(xo, te.thread_axis("blockIdx.x"))
8787
# Build the dynamic lib.
8888
# If we don't want to do metal and only use cpu, just set target to be target
89-
f = tvm.build(s, [A, B], "opencl", target_host=target, name="myadd")
89+
f = tvm.build(s, [A, B], tvm.target.Target("opencl", host=target), name="myadd")
9090
path_dso_cl = temp.relpath("dev_lib_cl.so")
9191
f.export_library(path_dso_cl, ndk.create_shared)
9292

@@ -109,7 +109,7 @@ def test_rpc_module():
109109
s[B].bind(xo, te.thread_axis("blockIdx.x"))
110110
# Build the dynamic lib.
111111
# If we don't want to do metal and only use cpu, just set target to be target
112-
f = tvm.build(s, [A, B], "vulkan", target_host=target, name="myadd")
112+
f = tvm.build(s, [A, B], tvm.target.Target("vulkan", host=target), name="myadd")
113113
path_dso_vulkan = temp.relpath("dev_lib_vulkan.so")
114114
f.export_library(path_dso_vulkan, ndk.create_shared)
115115

apps/benchmark/arm_cpu_imagenet_bench.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def evaluate_network(network, target, target_host, repeat):
4040

4141
print_progress("%-20s building..." % network)
4242
with tvm.transform.PassContext(opt_level=3):
43-
lib = relay.build(net, target=target, target_host=target_host, params=params)
43+
lib = relay.build(net, target=tvm.target.Target(target, host=target_host), params=params)
4444

4545
tmp = tempdir()
4646
if "android" in str(target):

apps/benchmark/mobile_gpu_imagenet_bench.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def evaluate_network(network, target, target_host, dtype, repeat):
4040

4141
print_progress("%-20s building..." % network)
4242
with tvm.transform.PassContext(opt_level=3):
43-
lib = relay.build(net, target=target, target_host=target_host, params=params)
43+
lib = relay.build(net, target=tvm.target.Target(target, host=target_host), params=params)
4444

4545
tmp = tempdir()
4646
if "android" in str(target) or "android" in str(target_host):

apps/hexagon_launcher/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
## Compilation
2020

2121
The launcher consists of two parts: part running on Hexagon, and part running
22-
on Android. Each component must be compiled separately.
22+
on Android. Each component must be compiled separately.
2323

2424
The supported Snapdragon architectures are 855, 865, and 888.
2525

@@ -37,9 +37,9 @@ Building the Hexagon launcher application as a component of the main TVM build
3737
used for Hexagon codegen can be achieved by setting `USE_HEXAGON_LAUNCHER=ON`.
3838
This option will compile core tvm, the android launcher binary and its corresponding
3939
tvm_runtime, as well as the Hexagon launcher shared library and its corresponding
40-
tvm_runtime. As described in the [Manual compilation](#Manual compilation) section
41-
each component requires Hexagon and android dependencies. When building the launcher
42-
along with TVM these configurations must be providing when invoking cmake. A minimal
40+
tvm_runtime. As described in the [Manual compilation](#Manual compilation) section
41+
each component requires Hexagon and android dependencies. When building the launcher
42+
along with TVM these configurations must be providing when invoking cmake. A minimal
4343
example invocation for compiling TVM along with the Hexagon launcher is included below:
4444

4545
```
@@ -59,9 +59,9 @@ cmake -DCMAKE_C_COMPILER=/path/to/clang \
5959
```
6060

6161
where `v65|v66|v68` means "one of" these architecture versions.
62-
The Hexagon launcher application is an android binary and thus requires the use
63-
of an android toolchain for compilation. Similarly, the Hexagon tvm runtime
64-
requires the use of the Hexagon toolchain and depends on the Hexagon SDK. The
62+
The Hexagon launcher application is an android binary and thus requires the use
63+
of an android toolchain for compilation. Similarly, the Hexagon tvm runtime
64+
requires the use of the Hexagon toolchain and depends on the Hexagon SDK. The
6565
resulting hexagon launcher binaries can be found in the `apps_hexagon_launcher`
6666
subdirectory of the cmake build directory. Please note that the above command
6767
will not build support for Hexagon codegen in the TVM library, for that please
@@ -70,7 +70,7 @@ additionally define the `USE_HEXAGON_DEVICE` variable. Also, the LLVM used in
7070

7171
### Manual compilation
7272

73-
Since some source files are shared between the Hexagon and android builds,
73+
Since some source files are shared between the Hexagon and android builds,
7474
make sure to delete all object files between compilations. Compile the Hexagon
7575
code first.
7676

@@ -157,7 +157,7 @@ mod, params = relay.frontend.from_tflite(
157157
158158
target = tvm.target.hexagon('v68', link_params=True)
159159
with tvm.transform.PassContext(opt_level=3):
160-
lib = relay.build(mod, target, target_host=target, params=params, mod_name="default")
160+
lib = relay.build(mod, tvm.target.Target(target, host=target), params=params, mod_name="default")
161161
162162
# Save model.so and model.json:
163163
with open('model.json', 'w') as f:

apps/ios_rpc/tests/ios_rpc_mobilenet.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ def test_mobilenet(host, port, key, mode):
9393

9494
def run(mod, target):
9595
with relay.build_config(opt_level=3):
96-
lib = relay.build(mod, target=target, target_host=target_host, params=params)
96+
lib = relay.build(
97+
mod, target=tvm.target.Target(target, host=target_host), params=params
98+
)
9799
path_dso = temp.relpath("deploy.dylib")
98100
lib.export_library(path_dso, xcode.create_dylib, arch=arch, sdk=sdk)
99101

apps/ios_rpc/tests/ios_rpc_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_rpc_module(host, port, key, mode):
5555
s[B].bind(xo, te.thread_axis("blockIdx.x"))
5656
# Build the dynamic lib.
5757
# If we don't want to do metal and only use cpu, just set target to be target
58-
f = tvm.build(s, [A, B], "metal", target_host=target, name="myadd")
58+
f = tvm.build(s, [A, B], tvm.target.Target("metal", host=target), name="myadd")
5959
path_dso1 = temp.relpath("dev_lib.dylib")
6060
f.export_library(path_dso1, xcode.create_dylib, arch=arch, sdk=sdk)
6161

apps/topi_recipe/gemm/android_gemm_square.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def test_gemm_gpu(N, times, bn, num_block, num_thread):
120120

121121
print(tvm.lower(s, [A, B, C], simple_mode=True))
122122

123-
f = tvm.build(s, [A, B, C], "opencl", target_host=target, name="gemm_gpu")
123+
f = tvm.build(s, [A, B, C], tvm.target.Target("opencl", host=target), name="gemm_gpu")
124124
temp = utils.tempdir()
125125
path_dso = temp.relpath("gemm_gpu.so")
126126
f.export_library(path_dso, ndk.create_shared)

docs/how_to/deploy/bnns.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ After that you need to compile new module with target corresponding to required
130130
131131
model = partition_for_bnns(model, params=params) # to markup operations to be offloaded to BNNS
132132
with tvm.transform.PassContext(opt_level=3):
133-
lib = relay.build(model, target=target, target_host=target, params=params)
133+
lib = relay.build(model, target=target, params=params)
134134
135135
Export the module.
136136

docs/how_to/deploy/hls.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ We use two python scripts for this tutorial.
3434
import tvm
3535
from tvm import te
3636
37-
tgt_host="llvm"
38-
tgt="sdaccel"
37+
tgt= tvm.target.Target("sdaccel", host="llvm")
3938
4039
n = te.var("n")
4140
A = te.placeholder((n,), name='A')
@@ -47,7 +46,7 @@ We use two python scripts for this tutorial.
4746
4847
s[C].bind(px, tvm.te.thread_axis("pipeline"))
4948
50-
fadd = tvm.build(s, [A, B, C], tgt, target_host=tgt_host, name="myadd")
49+
fadd = tvm.build(s, [A, B, C], tgt, name="myadd")
5150
5251
fadd.save("myadd.o")
5352
fadd.imported_modules[0].save("myadd.xclbin")

0 commit comments

Comments
 (0)