Skip to content

Commit 40616c7

Browse files
committed
Add mistakenly ignored files to sgx eg
1 parent 3e52766 commit 40616c7

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

apps/sgx/enclave/build.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use std::env;
2+
3+
fn main() {
4+
println!(
5+
"cargo:rustc-link-search=native={}",
6+
env::var("BUILD_DIR").unwrap()
7+
);
8+
println!("cargo:rustc-link-lib=static=model");
9+
}

apps/sgx/enclave/src/build_model.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""Creates a simple TVM modules."""
2+
3+
import argparse
4+
import os
5+
from os import path as osp
6+
7+
import nnvm.compiler
8+
import nnvm.testing
9+
import tvm
10+
11+
12+
def main():
13+
parser = argparse.ArgumentParser()
14+
parser.add_argument('-o', '--out-dir', default='.')
15+
opts = parser.parse_args()
16+
17+
# from tutorials/nnvm_quick_start.py
18+
dshape = (1, 3, 224, 224)
19+
net, params = nnvm.testing.resnet.get_workload(
20+
layers=18, batch_size=dshape[0], image_shape=dshape[1:])
21+
22+
with nnvm.compiler.build_config(opt_level=3):
23+
graph, lib, params = nnvm.compiler.build(
24+
net, 'llvm --system-lib', shape={'data': dshape}, params=params)
25+
26+
build_dir = osp.abspath(opts.out_dir)
27+
if not osp.isdir(build_dir):
28+
os.makedirs(build_dir, exist_ok=True)
29+
30+
lib.save(osp.join(build_dir, 'model.bc'))
31+
with open(osp.join(build_dir, 'graph.json'), 'w') as f_graph_json:
32+
f_graph_json.write(graph.json())
33+
with open(osp.join(build_dir, 'params.bin'), 'wb') as f_params:
34+
f_params.write(nnvm.compiler.save_param_dict(params))
35+
36+
37+
if __name__ == '__main__':
38+
main()

0 commit comments

Comments
 (0)