Makefile 1.72 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# 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.

nhynes committed
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
MODEL ?= resnet
NUM_THREADS ?= 4
BATCH_SIZE ?= 64
TRAINING ?= true
DEBUG ?= false

build_dir := ../build

ifeq ($(DEBUG), false)
	debug := release
	xargo_args := --release
else
	debug := debug
endif

33 34 35
target=target/x86_64-unknown-linux-sgx/$(debug)/libmodel-enclave.a

$(target): $(build_dir)/libmodel.a **/* $(TVM_DIR)/rust/patched.txt
nhynes committed
36 37 38 39 40 41 42
	RUST_TARGET_PATH=$(shell pwd) \
		RUST_TARGET_DIR=$(shell pwd)/target \
		RUSTFLAGS="-Z force-unstable-if-unmarked" \
		TVM_NUM_THREADS=$(NUM_THREADS) \
		BUILD_DIR=../build \
		xargo build --target x86_64-unknown-linux-sgx $(xargo_args) -q

43 44 45 46 47
$(TVM_DIR)/rust/patched.txt: $(shell pwd)/sgx-deps.diff
	echo $(TVM_DIR)
	cd $(TVM_DIR) && git apply $<
	touch $@

nhynes committed
48
$(build_dir)/libmodel.a: $(build_dir)/model.o
49
	$(AR) cr $@ $^
nhynes committed
50 51

$(build_dir)/model.o: $(build_dir)/model.bc
52
	$(CC) -c $< -o $@ -fPIC -O3
nhynes committed
53 54 55 56 57 58 59
	objcopy --globalize-symbol __tvm_module_startup $@

$(build_dir)/model.bc: src/build_model.py
	python3 $< -o $(build_dir)

clean:
	xargo clean