Skip to content

Commit

Permalink
[µTVM] Add --runtime=c, remove micro_dev target, enable LLVM backend (a…
Browse files Browse the repository at this point in the history
…pache#6145)

* need to fill address of globals in tvmfuncregistry

* llvm func registry generator works!

* lint fixes

* rm hexdump include

* bring bundle_deploy back to life and add to CI

* revert gcda additions

* git-clang-format

* fix check for --system-lib and test_runtime_micro target

* fixup compile flags for bundle_deploy CRT and improve robustness

* git-clang-format

* add debugging info

* git-clang-format

* initialize ret_values in PackedFunc_Call.

* retrigger CI

* fix log messages

* git-clang-format

* remove default for --runtime target opt

* put backtrace behind a flag and enable it

* simpify ReadString(), fixing bad instruction exception on os x.

* git-clang-format

* uncomment tests

* reorder backtrace ldflags for linux gcc
  • Loading branch information
areusch authored and Trevor Morris committed Aug 26, 2020
1 parent a29f2d8 commit e80805d
Show file tree
Hide file tree
Showing 37 changed files with 761 additions and 244 deletions.
141 changes: 85 additions & 56 deletions apps/bundle_deploy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
TVM_ROOT=$(shell cd ../..; pwd)
CRT_ROOT ?= ../../src/runtime/crt

ENABLE_TVM_PLATFORM_ABORT_BACKTRACE ?= 1

DMLC_CORE=${TVM_ROOT}/3rdparty/dmlc-core
PKG_CXXFLAGS = -g -Wall -std=c++14 -O2 -fPIC \
PKG_COMPILE_OPTS = -g -Wall -O2 -fPIC
PKG_CXXFLAGS = ${PKG_COMPILE_OPTS} -std=c++14 \
-I${TVM_ROOT}/include \
-I${DMLC_CORE}/include \
-I${TVM_ROOT}/3rdparty/dlpack/include \
-Icrt_config
PKG_CFLAGS = -g -Wall -std=c99 -O2 -fPIC \
PKG_CFLAGS = ${PKG_COMPILE_OPTS} \
-I${TVM_ROOT}/include \
-I${DMLC_CORE}/include \
-I${TVM_ROOT}/3rdparty/dlpack/include \
Expand All @@ -37,90 +40,116 @@ PKG_LDFLAGS = -pthread

build_dir := build

BACKTRACE_SRCS =
BACKTRACE_LDFLAGS =
BACKTRACE_CFLAGS =
$(ifeq ENABLE_TVM_PLATFORM_ABORT_BACKTRACE,1)
BACKTRACE_SRCS += backtrace.c
BACKTRACE_LDFLAGS += -ldl
BACKTRACE_CFLAGS += -DENABLE_TVM_PLATFORM_ABORT_BACKTRACE
$(endif)

BACKTRACE_OBJS = $(patsubst %.c,$(build_dir)/%.o,$(BACKTRACE_SRCS))

$(ifeq VERBOSE,1)
QUIET ?=
$(else)
QUIET ?= @
$(endif)

demo_dynamic: $(build_dir)/demo_dynamic $(build_dir)/bundle.so $(build_dir)/bundle_c.so $(build_dir)/cat.bin
TVM_NUM_THREADS=1 $(build_dir)/demo_dynamic $(build_dir)/bundle.so $(build_dir)/cat.bin
TVM_NUM_THREADS=1 $(build_dir)/demo_dynamic $(build_dir)/bundle_c.so $(build_dir)/cat.bin

test_dynamic: $(build_dir)/test_dynamic $(build_dir)/test_bundle.so $(build_dir)/test_bundle_c.so $(build_dir)/test_data.bin $(build_dir)/test_output.bin
TVM_NUM_THREADS=1 $(build_dir)/test_dynamic $(build_dir)/test_bundle.so $(build_dir)/test_data.bin $(build_dir)/test_output.bin $(build_dir)/test_graph.json $(build_dir)/test_params.bin
TVM_NUM_THREADS=1 $(build_dir)/test_dynamic $(build_dir)/test_bundle_c.so $(build_dir)/test_data.bin $(build_dir)/test_output.bin $(build_dir)/test_graph.json $(build_dir)/test_params.bin
demo_dynamic: $(build_dir)/demo_dynamic $(build_dir)/bundle.so $(build_dir)/bundle_c.so $(build_dir)/bundle.so $(build_dir)/graph_cpp.json $(build_dir)/graph_c.json $(build_dir)/params_cpp.bin $(build_dir)/params_c.bin $(build_dir)/cat.bin
$(QUIET)TVM_NUM_THREADS=1 $(build_dir)/demo_dynamic $(build_dir)/bundle.so $(build_dir)/graph_cpp.json $(build_dir)/params_cpp.bin $(build_dir)/cat.bin
$(QUIET)TVM_NUM_THREADS=1 $(build_dir)/demo_dynamic $(build_dir)/bundle_c.so $(build_dir)/graph_c.json $(build_dir)/params_c.bin $(build_dir)/cat.bin

test_dynamic: $(build_dir)/test_dynamic $(build_dir)/test_bundle.so $(build_dir)/test_bundle_c.so $(build_dir)/test_data_c.bin $(build_dir)/test_output_c.bin $(build_dir)/test_data_cpp.bin $(build_dir)/test_output_cpp.bin
$(QUIET)TVM_NUM_THREADS=1 $(build_dir)/test_dynamic $(build_dir)/test_bundle.so $(build_dir)/test_data_cpp.bin $(build_dir)/test_output_cpp.bin $(build_dir)/test_graph_cpp.json $(build_dir)/test_params_cpp.bin
$(QUIET)TVM_NUM_THREADS=1 $(build_dir)/test_dynamic $(build_dir)/test_bundle_c.so $(build_dir)/test_data_c.bin $(build_dir)/test_output_c.bin $(build_dir)/test_graph_c.json $(build_dir)/test_params_c.bin

demo_static: $(build_dir)/demo_static $(build_dir)/cat.bin
TVM_NUM_THREADS=1 $(build_dir)/demo_static $(build_dir)/cat.bin
$(QUIET)TVM_NUM_THREADS=1 $(build_dir)/demo_static $(build_dir)/cat.bin

test_static: $(build_dir)/test_static $(build_dir)/test_data.bin $(build_dir)/test_output.bin
TVM_NUM_THREADS=1 $(build_dir)/test_static $(build_dir)/test_data.bin $(build_dir)/test_output.bin $(build_dir)/test_graph.json $(build_dir)/test_params.bin
test_static: $(build_dir)/test_static $(build_dir)/test_data_c.bin $(build_dir)/test_output_c.bin
$(QUIET)TVM_NUM_THREADS=1 $(build_dir)/test_static $(build_dir)/test_data_c.bin $(build_dir)/test_output_c.bin $(build_dir)/test_graph_c.json $(build_dir)/test_params_c.bin

$(build_dir)/crt/graph_runtime/libgraph_runtime.a:
cd $(CRT_ROOT) && make QUIET= BUILD_DIR=$(abspath $(build_dir))/crt CRT_CONFIG=$(abspath crt_config/crt_config.h) graph_runtime
$(QUIET)cd $(CRT_ROOT) && make QUIET= BUILD_DIR=$(abspath $(build_dir))/crt CRT_CONFIG=$(abspath crt_config/crt_config.h) "EXTRA_CFLAGS=$(PKG_COMPILE_OPTS)" graph_runtime

$(build_dir)/crt/common/libcommon.a:
cd $(CRT_ROOT) && make QUIET= BUILD_DIR=$(abspath $(build_dir))/crt CRT_CONFIG=$(abspath crt_config/crt_config.h) common
$(QUIET)cd $(CRT_ROOT) && make QUIET= BUILD_DIR=$(abspath $(build_dir))/crt CRT_CONFIG=$(abspath crt_config/crt_config.h) "EXTRA_CFLAGS=$(PKG_COMPILE_OPTS)" common

$(build_dir)/demo_dynamic: demo.cc ${build_dir}/graph.json.c ${build_dir}/params.bin.c
@mkdir -p $(@D)
g++ $(PKG_CXXFLAGS) -o $@ demo.cc -ldl
$(build_dir)/demo_dynamic: demo.cc
$(QUIET)mkdir -p $(@D)
$(QUIET)g++ $(PKG_CXXFLAGS) -o $@ demo.cc $(BACKTRACE_LDFLAGS)

$(build_dir)/test_dynamic: test.cc ${build_dir}/test_graph.json ${build_dir}/test_params.bin
@mkdir -p $(@D)
g++ $(PKG_CXXFLAGS) -o $@ test.cc -ldl
$(build_dir)/test_dynamic: test.cc ${build_dir}/test_graph_c.json ${build_dir}/test_params_c.bin $(BACKTRACE_OBJS)
$(QUIET)mkdir -p $(@D)
$(QUIET)g++ $(PKG_CXXFLAGS) -o $@ test.cc $(BACKTRACE_OBJS) $(BACKTRACE_LDFLAGS)

$(build_dir)/model.o: $(build_dir)/model.c
gcc $(PKG_CFLAGS) -c -o $@ $^
$(build_dir)/demo_static: demo_static.c ${build_dir}/bundle_static.o ${build_dir}/model_c.o ${build_dir}/crt/graph_runtime/libgraph_runtime.a ${build_dir}/crt/common/libcommon.a $(BACKTRACE_OBJS)
$(QUIET)mkdir -p $(@D)
$(QUIET)gcc $(PKG_CFLAGS) -o $@ $^ $(BACKTRACE_CFLAGS)

$(build_dir)/demo_static: demo_static.c ${build_dir}/bundle_static.o ${build_dir}/func_registry.c ${build_dir}/model.o ${build_dir}/graph.json.c ${build_dir}/params.bin.c ${build_dir}/crt/graph_runtime/libgraph_runtime.a ${build_dir}/crt/common/libcommon.a
@mkdir -p $(@D)
gcc $(PKG_CFLAGS) -o $@ demo_static.c ${build_dir}/bundle_static.o ${build_dir}/func_registry.c ${build_dir}/model.o -lm ${build_dir}/crt/graph_runtime/libgraph_runtime.a ${build_dir}/crt/common/libcommon.a
$(build_dir)/test_static: test_static.c ${build_dir}/bundle_static.o ${build_dir}/test_model_c.o ${build_dir}/crt/graph_runtime/libgraph_runtime.a ${build_dir}/crt/common/libcommon.a $(BACKTRACE_OBJS)
$(QUIET)mkdir -p $(@D)
$(QUIET)gcc $(PKG_CFLAGS) -o $@ $^ $(BACKTRACE_LDFLAGS)

$(build_dir)/test_static: test_static.c ${build_dir}/bundle_static.o ${build_dir}/test_func_registry.c ${build_dir}/test_model.o ${build_dir}/crt/graph_runtime/libgraph_runtime.a ${build_dir}/crt/common/libcommon.a
@mkdir -p $(@D)
gcc $(PKG_CFLAGS) -o $@ $^
$(build_dir)/backtrace.o: backtrace.c
$(QUIET)mkdir -p $(@D)
$(QUIET)gcc -c $(PKG_CFLAGS) -o $@ $^ $(BACKTRACE_CFLAGS)

# Serialize our graph.json file.
$(build_dir)/graph.json.c: $(build_dir)/graph.json
xxd -i $^ > $@
$(build_dir)/graph_cpp.json.c: $(build_dir)/graph_cpp.json
$(QUIET)xxd -i $^ > $@

# Serialize our params.bin file.
$(build_dir)/params.bin.c: $(build_dir)/params.bin
xxd -i $^ > $@
$(build_dir)/graph_c.json.c: $(build_dir)/graph_c.json
$(QUIET)xxd -i $^ > $@

$(build_dir)/func_registry.c $(build_dir)/model.c $(build_dir)/graph.json $(build_dir)/params.bin $(build_dir)/cat.bin: build_model.py
python3 $< -o $(build_dir)
# Serialize our params.bin file.
$(build_dir)/params_c.bin.c: $(build_dir)/params_c.bin
$(QUIET)xxd -i $^ > $@

$(build_dir)/test_func_registry.c $(build_dir)/test_model.c $(build_dir)/test_graph.json $(build_dir)/test_params.bin $(build_dir)/test_data.bin $(build_dir)/test_output.bin: build_model.py
python3 $< -o $(build_dir) --test
$(build_dir)/params_cpp.bin.c: $(build_dir)/params_cpp.bin
$(QUIET)xxd -i $^ > $@

$(build_dir)/test_model.o: $(build_dir)/test_model.c
gcc $(PKG_CFLAGS) -c -o $@ $^
$(build_dir)/model_c.o $(build_dir)/graph_c.json $(build_dir)/model_cpp.o $(build_dir)/graph_cpp.json $(build_dir)/params.bin $(build_dir)/cat.bin: build_model.py
$(QUIET)python3 $< -o $(build_dir)

$(build_dir)/func_registry.o: $(build_dir)/func_registry.c
gcc $(PKG_CFLAGS) -c -o $@ $^
$(build_dir)/test_model_c.o $(build_dir)/test_graph_c.json $(build_dir)/test_params_c.bin $(build_dir)/test_data_c.bin $(build_dir)/test_output_c.bin $(build_dir)/test_model_cpp.o $(build_dir)/test_graph_cpp.json $(build_dir)/test_params_cpp.bin $(build_dir)/test_data_cpp.bin $(build_dir)/test_output_cpp.bin: build_model.py
$(QUIET)python3 $< -o $(build_dir) --test

# Build our bundle against the serialized bundle.c API, the runtime.cc API, and
# the serialized graph.json and params.bin
$(build_dir)/bundle.so: bundle.cc $(build_dir)/model.o $(build_dir)/func_registry.o ${build_dir}/crt/graph_runtime/libgraph_runtime.a ${build_dir}/crt/common/libcommon.a
@mkdir -p $(@D)
g++ -shared $(PKG_CXXFLAGS) -fvisibility=hidden -o $@ $^ $(PKG_LDFLAGS)
$(build_dir)/bundle.so: bundle.cc runtime.cc $(build_dir)/model_cpp.o
$(QUIET)mkdir -p $(@D)
$(QUIET)g++ -shared $(PKG_CXXFLAGS) -fvisibility=hidden -o $@ $^ $(PKG_LDFLAGS)

$(build_dir)/bundle_c.so: bundle.c runtime.c $(build_dir)/model.o $(build_dir)/func_registry.c
@mkdir -p $(@D)
gcc -shared $(PKG_CFLAGS) -fvisibility=hidden -o $@ $^ $(PKG_LDFLAGS)
$(build_dir)/bundle_c.so: bundle.c $(build_dir)/model_c.o ${build_dir}/crt/graph_runtime/libgraph_runtime.a ${build_dir}/crt/common/libcommon.a $(BACKTRACE_OBJS)
$(QUIET)mkdir -p $(@D)
$(QUIET)gcc -shared $(PKG_CFLAGS) -fvisibility=hidden -o $@ $^ $(PKG_LDFLAGS) $(BACKTRACE_LDFLAGS) $(BACKTRACE_CFLAGS)

$(build_dir)/test_bundle.so: bundle.cc runtime.cc $(build_dir)/test_model.o $(build_dir)/test_func_registry.c
@mkdir -p $(@D)
g++ -shared $(PKG_CXXFLAGS) -fvisibility=hidden -o $@ $^ $(PKG_LDFLAGS)
$(build_dir)/test_bundle.so: bundle.cc runtime.cc $(build_dir)/test_model_cpp.o
$(QUIET)mkdir -p $(@D)
$(QUIET)g++ -shared $(PKG_CXXFLAGS) -fvisibility=hidden -o $@ $^ $(PKG_LDFLAGS)

$(build_dir)/test_bundle_c.so: bundle.c runtime.c $(build_dir)/test_model.o $(build_dir)/test_func_registry.c
@mkdir -p $(@D)
gcc -shared $(PKG_CFLAGS) -fvisibility=hidden -o $@ $^ $(PKG_LDFLAGS)
$(build_dir)/test_bundle_c.so: bundle.c $(build_dir)/test_model_c.o ${build_dir}/crt/graph_runtime/libgraph_runtime.a ${build_dir}/crt/common/libcommon.a $(BACKTRACE_OBJS)
$(QUIET)mkdir -p $(@D)
$(QUIET)gcc -shared $(PKG_CFLAGS) -fvisibility=hidden -o $@ $^ $(PKG_LDFLAGS) $(BACKTRACE_LDFLAGS) $(BACKTRACE_CFLAGS)

$(build_dir)/bundle_static.o: bundle_static.c
@mkdir -p $(@D)
gcc -c $(PKG_CFLAGS) -o $@ $^
$(QUIET)mkdir -p $(@D)
$(QUIET)gcc -c $(PKG_CFLAGS) -o $@ $^ $(BACKTRACE_CFLAGS)

clean:
rm -rf $(build_dir)/bundle.so $(build_dir)/bundle_c.so $(build_dir)/test_bundle.so $(build_dir)/test_bundle_c.so $(build_dir)/crt
$(QUIET)rm -rf $(build_dir)/bundle.so $(build_dir)/bundle_c.so $(build_dir)/test_bundle.so $(build_dir)/test_bundle_c.so $(build_dir)/crt

cleanall:
rm -rf $(build_dir)
$(QUIET)rm -rf $(build_dir)

# Don't define implicit rules; they tend to match on logical target names that aren't targets (i.e. bundle_static)
.SUFFIXES:

.DEFAULT: demo_static demo_dynamic

test: test_static test_dynamic
.PHONY: test
57 changes: 57 additions & 0 deletions apps/bundle_deploy/backtrace.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#define _GNU_SOURCE
#include "backtrace.h"

#include <dlfcn.h>
#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

const char* g_argv0 = NULL;

void tvm_platform_abort_backtrace() {
void* trace[200];
int nptrs = backtrace(trace, sizeof(trace) / sizeof(void*));
fprintf(stderr, "backtrace: %d\n", nptrs);
if (nptrs < 0) {
perror("backtracing");
} else {
backtrace_symbols_fd(trace, nptrs, STDOUT_FILENO);

char cmd_buf[1024];
for (int i = 0; i < nptrs; i++) {
Dl_info info;
if (dladdr(trace[i], &info)) {
fprintf(stderr, "symbol %d: %s %s %p (%p)\n", i, info.dli_sname, info.dli_fname,
info.dli_fbase, (void*)(trace[i] - info.dli_fbase));
snprintf(cmd_buf, sizeof(cmd_buf), "addr2line --exe=%s -p -i -a -f %p", g_argv0,
(void*)(trace[i] - info.dli_fbase));
int result = system(cmd_buf);
if (result < 0) {
perror("invoking backtrace command");
}
} else {
fprintf(stderr, "symbol %d: %p (unmapped)\n", i, trace[i]);
}
}
}
}
30 changes: 30 additions & 0 deletions apps/bundle_deploy/backtrace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#ifdef __cplusplus
extern "C" {
#endif

extern const char* g_argv0;

void tvm_platform_abort_backtrace(void);

#ifdef __cplusplus
}
#endif
69 changes: 36 additions & 33 deletions apps/bundle_deploy/build_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@
from tvm import relay
import tvm
from tvm import te
from tvm.micro import func_registry
import logging
import json

RUNTIMES = {
'c': '{name}_c.{ext}',
'c++': '{name}_cpp.{ext}',
}

def build_module(opts):
dshape = (1, 3, 224, 224)
from mxnet.gluon.model_zoo.vision import get_model
Expand All @@ -34,21 +38,20 @@ def build_module(opts):
func = mod["main"]
func = relay.Function(func.params, relay.nn.softmax(func.body), None, func.type_params, func.attrs)

with tvm.transform.PassContext(opt_level=3, config={'tir.disable_vectorize': True}):
graph, lib, params = relay.build(
func, 'c', params=params)
for runtime_name, file_format_str in RUNTIMES.items():
with tvm.transform.PassContext(opt_level=3, config={'tir.disable_vectorize': True}):
graph, lib, params = relay.build(
func, f'llvm --runtime={runtime_name} --system-lib', params=params)

build_dir = os.path.abspath(opts.out_dir)
if not os.path.isdir(build_dir):
os.makedirs(build_dir)
build_dir = os.path.abspath(opts.out_dir)
if not os.path.isdir(build_dir):
os.makedirs(build_dir)

lib.save(os.path.join(build_dir, 'model.c'), 'cc')
with open(os.path.join(build_dir, 'graph.json'), 'w') as f_graph_json:
f_graph_json.write(graph)
with open(os.path.join(build_dir, 'params.bin'), 'wb') as f_params:
f_params.write(relay.save_param_dict(params))
func_registry.graph_json_to_c_func_registry(os.path.join(build_dir, 'graph.json'),
os.path.join(build_dir, 'func_registry.c'))
lib.save(os.path.join(build_dir, file_format_str.format(name='model', ext='o')))
with open(os.path.join(build_dir, file_format_str.format(name='graph', ext='json')), 'w') as f_graph_json:
f_graph_json.write(graph)
with open(os.path.join(build_dir, file_format_str.format(name='params', ext='bin')), 'wb') as f_params:
f_params.write(relay.save_param_dict(params))

def build_test_module(opts):
import numpy as np
Expand All @@ -60,26 +63,26 @@ def build_test_module(opts):
x_data = np.random.rand(10, 5).astype('float32')
y_data = np.random.rand(1, 5).astype('float32')
params = {"y": y_data}
with tvm.transform.PassContext(opt_level=3, config={'tir.disable_vectorize': True}):
graph, lib, params = relay.build(
tvm.IRModule.from_expr(func), "c", params=params)

build_dir = os.path.abspath(opts.out_dir)
if not os.path.isdir(build_dir):
os.makedirs(build_dir)

lib.save(os.path.join(build_dir, 'test_model.c'), 'cc')
with open(os.path.join(build_dir, 'test_graph.json'), 'w') as f_graph_json:
f_graph_json.write(graph)
with open(os.path.join(build_dir, 'test_params.bin'), 'wb') as f_params:
f_params.write(relay.save_param_dict(params))
with open(os.path.join(build_dir, "test_data.bin"), "wb") as fp:
fp.write(x_data.astype(np.float32).tobytes())
func_registry.graph_json_to_c_func_registry(os.path.join(build_dir, 'test_graph.json'),
os.path.join(build_dir, 'test_func_registry.c'))
x_output = x_data + y_data
with open(os.path.join(build_dir, "test_output.bin"), "wb") as fp:
fp.write(x_output.astype(np.float32).tobytes())
for runtime_name, file_format_str in RUNTIMES.items():
with tvm.transform.PassContext(opt_level=3, config={'tir.disable_vectorize': True}):
graph, lib, lowered_params = relay.build(
tvm.IRModule.from_expr(func), f"llvm --runtime={runtime_name} --system-lib", params=params)

build_dir = os.path.abspath(opts.out_dir)
if not os.path.isdir(build_dir):
os.makedirs(build_dir)

lib.save(os.path.join(build_dir, file_format_str.format(name='test_model', ext='o')))
with open(os.path.join(build_dir, file_format_str.format(name='test_graph', ext='json')), 'w') as f_graph_json:
f_graph_json.write(graph)
with open(os.path.join(build_dir, file_format_str.format(name='test_params', ext='bin')), 'wb') as f_params:
f_params.write(relay.save_param_dict(lowered_params))
with open(os.path.join(build_dir, file_format_str.format(name="test_data", ext="bin")), "wb") as fp:
fp.write(x_data.astype(np.float32).tobytes())
x_output = x_data + y_data
with open(os.path.join(build_dir, file_format_str.format(name="test_output", ext="bin")), "wb") as fp:
fp.write(x_output.astype(np.float32).tobytes())

def build_inputs(opts):
from tvm.contrib import download
Expand Down
Loading

0 comments on commit e80805d

Please sign in to comment.