Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SGX] Add ignored files to sgx example #1852

Merged
merged 2 commits into from
Oct 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions apps/sgx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ Check out the `/tvm/install/ubuntu_install_sgx.sh` for the commands to get these

## Running the example

If using Docker, start by running

```
git clone https://github.com/dmlc/tvm.git
docker run --rm -it -v $(pwd)/tvm:/mnt tvmai/ci-cpu /bin/bash
```
then, in the container
```
cd /mnt
mkdir build && cd build
cmake .. -DUSE_LLVM=ON -DUSE_SGX=/opt/sgxsdk -DRUST_SGX_SDK=/opt/rust-sgx-sdk
make -j4
cd ../apps/sgx
```

`bash run_example.sh`

If everything goes well, you should see a lot of build messages and below them
Expand Down
9 changes: 9 additions & 0 deletions apps/sgx/enclave/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use std::env;

fn main() {
println!(
"cargo:rustc-link-search=native={}",
env::var("BUILD_DIR").unwrap()
);
println!("cargo:rustc-link-lib=static=model");
}
38 changes: 38 additions & 0 deletions apps/sgx/enclave/src/build_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""Creates a simple TVM modules."""

import argparse
import os
from os import path as osp

import nnvm.compiler
import nnvm.testing
import tvm


def main():
parser = argparse.ArgumentParser()
parser.add_argument('-o', '--out-dir', default='.')
opts = parser.parse_args()

# from tutorials/nnvm_quick_start.py
dshape = (1, 3, 224, 224)
net, params = nnvm.testing.resnet.get_workload(
layers=18, batch_size=dshape[0], image_shape=dshape[1:])

with nnvm.compiler.build_config(opt_level=3):
graph, lib, params = nnvm.compiler.build(
net, 'llvm --system-lib', shape={'data': dshape}, params=params)

build_dir = osp.abspath(opts.out_dir)
if not osp.isdir(build_dir):
os.makedirs(build_dir, exist_ok=True)

lib.save(osp.join(build_dir, 'model.bc'))
with open(osp.join(build_dir, 'graph.json'), 'w') as f_graph_json:
f_graph_json.write(graph.json())
with open(osp.join(build_dir, 'params.bin'), 'wb') as f_params:
f_params.write(nnvm.compiler.save_param_dict(params))


if __name__ == '__main__':
main()