Open uday60 opened 4 years ago
import numpy as np import nnvm.compiler import nnvm.testing import tvm from tvm.contrib import graph_runtime import mxnet as mx from mxnet import ndarray as nd prefix,epoch = "/home/xyz/Downloads/github/insightface/gender-age/model/model",0 sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) image_size = (112, 112) opt_level = 3 shape_dict = {'data': (1, 3, *image_size)} #target = tvm.target.create("llvm -mcpu=skylake") #target = tvm.target.cuda("llvm device=0") # "target" means your target platform you want to compile. target = tvm.target.create("llvm -mcpu=broadwell") nnvm_sym, nnvm_params = nnvm.frontend.from_mxnet(sym, arg_params, aux_params) with nnvm.compiler.build_config(opt_level=opt_level): graph, lib, params = nnvm.compiler.build(nnvm_sym, target, shape_dict, params=nnvm_params) lib.export_library("./model_ga_cpu.so") print('lib export succeefully') with open("./model_ga_cpu.json", "w") as fo: fo.write(graph.json()) with open("./model_ga_cpu.params", "wb") as fo: fo.write(nnvm.compiler.save_param_dict(params))
Output:
[16:35:49] src/nnvm/legacy_json_util.cc:209: Loading symbol saved by previous version v1.3.0. Attempting to upgrade... [16:35:49] src/nnvm/legacy_json_util.cc:217: Symbol successfully upgraded! Cannot find config for target=llvm -mcpu=broadwell, workload=('conv2d', (1, 3, 112, 112, 'float32'), (8, 3, 3, 3, 'float32'), (1, 1), (1, 1), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression. Cannot find config for target=llvm -mcpu=broadwell, workload=('depthwise_conv2d_nchw', (1, 8, 112, 112, 'float32'), (8, 1, 3, 3, 'float32'), (1, 1), (1, 1), (1, 1), 'float32'). A fallback configuration is used, which may bring great performance regression. Cannot find config for target=llvm -mcpu=broadwell, workload=('conv2d', (1, 8, 112, 112, 'float32'), (16, 8, 1, 1, 'float32'), (1, 1), (0, 0), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression. Cannot find config for target=llvm -mcpu=broadwell, workload=('depthwise_conv2d_nchw', (1, 16, 112, 112, 'float32'), (16, 1, 3, 3, 'float32'), (2, 2), (1, 1), (1, 1), 'float32'). A fallback configuration is used, which may bring great performance regression. Cannot find config for target=llvm -mcpu=broadwell, workload=('conv2d', (1, 16, 56, 56, 'float32'), (32, 16, 1, 1, 'float32'), (1, 1), (0, 0), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression. Cannot find config for target=llvm -mcpu=broadwell, workload=('depthwise_conv2d_nchw', (1, 32, 56, 56, 'float32'), (32, 1, 3, 3, 'float32'), (1, 1), (1, 1), (1, 1), 'float32'). A fallback configuration is used, which may bring great performance regression. Cannot find config for target=llvm -mcpu=broadwell, workload=('conv2d', (1, 32, 56, 56, 'float32'), (32, 32, 1, 1, 'float32'), (1, 1), (0, 0), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression. Cannot find config for target=llvm -mcpu=broadwell, workload=('depthwise_conv2d_nchw', (1, 32, 56, 56, 'float32'), (32, 1, 3, 3, 'float32'), (2, 2), (1, 1), (1, 1), 'float32'). A fallback configuration is used, which may bring great performance regression. Cannot find config for target=llvm -mcpu=broadwell, workload=('conv2d', (1, 32, 28, 28, 'float32'), (64, 32, 1, 1, 'float32'), (1, 1), (0, 0), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression. Cannot find config for target=llvm -mcpu=broadwell, workload=('depthwise_conv2d_nchw', (1, 64, 28, 28, 'float32'), (64, 1, 3, 3, 'float32'), (1, 1), (1, 1), (1, 1), 'float32'). A fallback configuration is used, which may bring great performance regression. Cannot find config for target=llvm -mcpu=broadwell, workload=('conv2d', (1, 64, 28, 28, 'float32'), (64, 64, 1, 1, 'float32'), (1, 1), (0, 0), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression. Cannot find config for target=llvm -mcpu=broadwell, workload=('depthwise_conv2d_nchw', (1, 64, 28, 28, 'float32'), (64, 1, 3, 3, 'float32'), (2, 2), (1, 1), (1, 1), 'float32'). A fallback configuration is used, which may bring great performance regression. Cannot find config for target=llvm -mcpu=broadwell, workload=('conv2d', (1, 64, 14, 14, 'float32'), (128, 64, 1, 1, 'float32'), (1, 1), (0, 0), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression. Cannot find config for target=llvm -mcpu=broadwell, workload=('depthwise_conv2d_nchw', (1, 128, 14, 14, 'float32'), (128, 1, 3, 3, 'float32'), (1, 1), (1, 1), (1, 1), 'float32'). A fallback configuration is used, which may bring great performance regression. Cannot find config for target=llvm -mcpu=broadwell, workload=('conv2d', (1, 128, 14, 14, 'float32'), (128, 128, 1, 1, 'float32'), (1, 1), (0, 0), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression. Cannot find config for target=llvm -mcpu=broadwell, workload=('depthwise_conv2d_nchw', (1, 128, 14, 14, 'float32'), (128, 1, 3, 3, 'float32'), (2, 2), (1, 1), (1, 1), 'float32'). A fallback configuration is used, which may bring great performance regression. Cannot find config for target=llvm -mcpu=broadwell, workload=('conv2d', (1, 128, 7, 7, 'float32'), (256, 128, 1, 1, 'float32'), (1, 1), (0, 0), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression. Cannot find config for target=llvm -mcpu=broadwell, workload=('depthwise_conv2d_nchw', (1, 256, 7, 7, 'float32'), (256, 1, 3, 3, 'float32'), (1, 1), (1, 1), (1, 1), 'float32'). A fallback configuration is used, which may bring great performance regression. Cannot find config for target=llvm -mcpu=broadwell, workload=('conv2d', (1, 256, 7, 7, 'float32'), (256, 256, 1, 1, 'float32'), (1, 1), (0, 0), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression. Traceback (most recent call last): File "convert.py", line 23, in <module> lib.export_library("./model_ga_cpu.so") File "/opt/softwares/tvm/python/tvm/module.py", line 128, in export_library fcompile(file_name, files, **kwargs) File "/opt/softwares/tvm/python/tvm/contrib/cc.py", line 33, in create_shared _linux_shared(output, objects, options, cc) File "/opt/softwares/tvm/python/tvm/contrib/cc.py", line 58, in _linux_shared raise RuntimeError(msg) RuntimeError: Compilation error: /usr/bin/ld: /tmp/tmpiczs4sg5/lib.o: relocation R_X86_64_32S against `.rodata.cst4' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: error: ld returned 1 exit status
@nttstar I am stuck ...really need your help guys.
Anyone ?
Try TVM forums.
Output: