Commit 43525f66 by Nick Hynes Committed by Tianqi Chen

[Rust] Add rust runtime to CI (#1851)

parent 2c9d70ad
max_width = 100
hard_tabs = false
tab_spaces = 2
newline_style = "Auto"
use_small_heuristics = "Default"
indent_style = "Block"
wrap_comments = false
comment_width = 80
normalize_comments = false
format_strings = false
format_macro_matchers = false
format_macro_bodies = true
empty_item_single_line = true
struct_lit_single_line = true
fn_single_line = false
where_single_line = false
imports_indent = "Block"
imports_layout = "Mixed"
merge_imports = true
reorder_imports = true
reorder_modules = true
reorder_impl_items = false
type_punctuation_density = "Wide"
space_before_colon = false
space_after_colon = true
spaces_around_ranges = false
binop_separator = "Front"
remove_nested_parens = true
combine_control_expr = true
struct_field_align_threshold = 0
match_arm_blocks = true
force_multiline_blocks = false
fn_args_density = "Tall"
brace_style = "SameLineWhere"
control_brace_style = "AlwaysSameLine"
trailing_semicolon = true
trailing_comma = "Vertical"
match_block_trailing_comma = true
blank_lines_upper_bound = 1
blank_lines_lower_bound = 0
edition = "2015"
merge_derives = true
use_try_shorthand = true
use_field_init_shorthand = false
force_explicit_abi = true
condense_wildcard_suffixes = true
color = "Auto"
required_version = "0.99.5"
unstable_features = false
disable_all_formatting = false
skip_children = false
hide_parse_errors = false
error_on_line_overflow = false
error_on_unformatted = false
report_todo = "Never"
report_fixme = "Never"
ignore = []
emit_mode = "Files"
make_backup = false
../../../rust/.rustfmt.toml
\ No newline at end of file
...@@ -15,24 +15,24 @@ RUN bash /install/ubuntu_install_python_package.sh ...@@ -15,24 +15,24 @@ RUN bash /install/ubuntu_install_python_package.sh
COPY install/ubuntu_install_llvm.sh /install/ubuntu_install_llvm.sh COPY install/ubuntu_install_llvm.sh /install/ubuntu_install_llvm.sh
RUN bash /install/ubuntu_install_llvm.sh RUN bash /install/ubuntu_install_llvm.sh
# AutoTVM deps # SGX deps (build early; changes infrequently)
COPY install/ubuntu_install_redis.sh /install/ubuntu_install_redis.sh COPY install/ubuntu_install_sgx.sh /install/ubuntu_install_sgx.sh
RUN bash /install/ubuntu_install_redis.sh RUN bash /install/ubuntu_install_sgx.sh
ENV LD_LIBRARY_PATH /opt/sgxsdk/lib64:${LD_LIBRARY_PATH}
# Golang environment
COPY install/ubuntu_install_golang.sh /install/ubuntu_install_golang.sh
RUN bash /install/ubuntu_install_golang.sh
# Rust env # Rust env (build early; takes a while)
COPY install/ubuntu_install_rust.sh /install/ubuntu_install_rust.sh COPY install/ubuntu_install_rust.sh /install/ubuntu_install_rust.sh
RUN bash /install/ubuntu_install_rust.sh RUN bash /install/ubuntu_install_rust.sh
ENV RUSTUP_HOME /opt/rust ENV RUSTUP_HOME /opt/rust
ENV CARGO_HOME /opt/rust ENV CARGO_HOME /opt/rust
ENV RUSTC_WRAPPER sccache
# SGX deps # AutoTVM deps
COPY install/ubuntu_install_sgx.sh /install/ubuntu_install_sgx.sh COPY install/ubuntu_install_redis.sh /install/ubuntu_install_redis.sh
RUN bash /install/ubuntu_install_sgx.sh RUN bash /install/ubuntu_install_redis.sh
ENV LD_LIBRARY_PATH /opt/sgxsdk/lib64:${LD_LIBRARY_PATH}
# Golang environment
COPY install/ubuntu_install_golang.sh /install/ubuntu_install_golang.sh
RUN bash /install/ubuntu_install_golang.sh
ENV PATH $PATH:$CARGO_HOME/bin:/usr/lib/go-1.10/bin ENV PATH $PATH:$CARGO_HOME/bin:/usr/lib/go-1.10/bin
...@@ -7,9 +7,9 @@ curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path --default-toolchai ...@@ -7,9 +7,9 @@ curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path --default-toolchai
. $CARGO_HOME/env . $CARGO_HOME/env
rustup toolchain add nightly rustup toolchain add nightly
rustup component add rust-src rustup component add rust-src
cargo +nightly install sccache
cargo +nightly install rustfmt-nightly --version 0.99.5 --force cargo +nightly install rustfmt-nightly --version 0.99.5 --force
cargo +nightly install xargo cargo +nightly install xargo
# make rust usable by all users # make rust usable by all users
chmod a+w /opt/rust chmod -R a+w /opt/rust
sudo find /opt/rust -type d -exec chmod a+w {} \;
...@@ -38,14 +38,14 @@ trailing_comma = "Vertical" ...@@ -38,14 +38,14 @@ trailing_comma = "Vertical"
match_block_trailing_comma = false match_block_trailing_comma = false
blank_lines_upper_bound = 1 blank_lines_upper_bound = 1
blank_lines_lower_bound = 0 blank_lines_lower_bound = 0
edition = "Edition2015" edition = "2015"
merge_derives = true merge_derives = true
use_try_shorthand = true use_try_shorthand = true
use_field_init_shorthand = false use_field_init_shorthand = false
force_explicit_abi = true force_explicit_abi = true
condense_wildcard_suffixes = false condense_wildcard_suffixes = false
color = "Auto" color = "Auto"
required_version = "0.99.4" required_version = "0.99.5"
unstable_features = false unstable_features = false
disable_all_formatting = false disable_all_formatting = false
skip_children = false skip_children = false
......
...@@ -173,7 +173,8 @@ impl<'a> Tensor<'a> { ...@@ -173,7 +173,8 @@ impl<'a> Tensor<'a> {
expected_stride * (*shape as usize), expected_stride * (*shape as usize),
) )
}, },
).0 )
.0
} }
} }
} }
......
...@@ -56,11 +56,13 @@ impl Graph { ...@@ -56,11 +56,13 @@ impl Graph {
.as_ref() .as_ref()
.ok_or(ErrorKind::GraphFormatError( .ok_or(ErrorKind::GraphFormatError(
"Missing graph attrs".to_string(), "Missing graph attrs".to_string(),
))?.get(attr) ))?
.get(attr)
.ok_or(ErrorKind::GraphFormatError(format!( .ok_or(ErrorKind::GraphFormatError(format!(
"Missing {} attr", "Missing {} attr",
attr attr
)))?.to_owned(), )))?
.to_owned(),
)?) )?)
} }
} }
...@@ -99,7 +101,8 @@ impl Node { ...@@ -99,7 +101,8 @@ impl Node {
.ok_or(format!( .ok_or(format!(
"Node `{}` is missing attrs.flatten_data", "Node `{}` is missing attrs.flatten_data",
self.name self.name
))?.parse::<u8>()? ))?
.parse::<u8>()?
== 1; == 1;
Ok(NodeAttrs { Ok(NodeAttrs {
func_name, func_name,
...@@ -189,7 +192,8 @@ impl<'m, 't> GraphExecutor<'m, 't> { ...@@ -189,7 +192,8 @@ impl<'m, 't> GraphExecutor<'m, 't> {
} else { } else {
Err(ErrorKind::GraphFormatError(format!("Invalid dltype: {}", dltype).to_string()).into()) Err(ErrorKind::GraphFormatError(format!("Invalid dltype: {}", dltype).to_string()).into())
} }
}).collect::<Result<Vec<DataType>>>()?; })
.collect::<Result<Vec<DataType>>>()?;
let align = dtypes.iter().map(|dtype| dtype.bits as usize).max(); let align = dtypes.iter().map(|dtype| dtype.bits as usize).max();
let mut storage_num_bytes = vec![0usize; *storage_ids.iter().max().unwrap_or(&1) + 1]; let mut storage_num_bytes = vec![0usize; *storage_ids.iter().max().unwrap_or(&1) + 1];
...@@ -216,7 +220,8 @@ impl<'m, 't> GraphExecutor<'m, 't> { ...@@ -216,7 +220,8 @@ impl<'m, 't> GraphExecutor<'m, 't> {
strides: None, strides: None,
byte_offset: 0, byte_offset: 0,
} }
}).collect(); })
.collect();
Ok(tensors) Ok(tensors)
} }
...@@ -261,7 +266,8 @@ impl<'m, 't> GraphExecutor<'m, 't> { ...@@ -261,7 +266,8 @@ impl<'m, 't> GraphExecutor<'m, 't> {
} else { } else {
DLTensor::from(tensor) DLTensor::from(tensor)
}) })
}).collect::<Result<Vec<DLTensor>>>() })
.collect::<Result<Vec<DLTensor>>>()
.unwrap(); .unwrap();
let op: Box<Fn()> = box move || { let op: Box<Fn()> = box move || {
let args = dl_tensors let args = dl_tensors
......
...@@ -58,7 +58,8 @@ impl Job { ...@@ -58,7 +58,8 @@ impl Job {
}, },
cdata: self.cdata, cdata: self.cdata,
pending: Arc::clone(&self.pending), pending: Arc::clone(&self.pending),
}).collect() })
.collect()
} }
/// Waits for all tasks in this `Job` to be completed. /// Waits for all tasks in this `Job` to be completed.
...@@ -110,7 +111,8 @@ impl<'a> Threads { ...@@ -110,7 +111,8 @@ impl<'a> Threads {
let (p, c) = bounded_spsc_queue::make(2); let (p, c) = bounded_spsc_queue::make(2);
let handle = thread::spawn(move || cb(c.into())); let handle = thread::spawn(move || cb(c.into()));
(handle, p) (handle, p)
}).unzip(); })
.unzip();
Threads { Threads {
handles: handles, handles: handles,
queues: queues, queues: queues,
...@@ -128,7 +130,8 @@ impl<'a> Threads { ...@@ -128,7 +130,8 @@ impl<'a> Threads {
let (p, c) = bounded_spsc_queue::make(2); let (p, c) = bounded_spsc_queue::make(2);
consumer_queues.push_back(c.into()); consumer_queues.push_back(c.into());
p p
}).collect(); })
.collect();
ocall_packed!("__sgx_thread_group_launch__", num_threads as u64); ocall_packed!("__sgx_thread_group_launch__", num_threads as u64);
Threads { queues: queues } Threads { queues: queues }
} }
......
...@@ -20,7 +20,8 @@ fn test_load_graph() { ...@@ -20,7 +20,8 @@ fn test_load_graph() {
let graph = Graph::try_from( let graph = Graph::try_from(
&fs::read_to_string(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/graph.json")).unwrap(), &fs::read_to_string(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/graph.json")).unwrap(),
).unwrap(); )
.unwrap();
assert_eq!(graph.nodes[3].op, "tvm_op"); assert_eq!(graph.nodes[3].op, "tvm_op");
assert_eq!( assert_eq!(
......
#!/bin/bash
set -e
export LD_LIBRARY_PATH=lib:$LD_LIBRARY_PATH
tvm_root="$(git rev-parse --show-toplevel)"
export PYTHONPATH="$tvm_root/python":"$tvm_root/nnvm/python":"$tvm_root/topi/python"
cd rust
cargo fmt -- --check
# run basic tests
python3 tests/build_model.py
cargo test --tests
# run TVM module test
cd tests/test_tvm_basic
cargo run
cd -
# run NNVM graph test
cd tests/test_nnvm
cargo run
cd -
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment