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
COPY install/ubuntu_install_llvm.sh /install/ubuntu_install_llvm.sh
RUN bash /install/ubuntu_install_llvm.sh
# AutoTVM deps
COPY install/ubuntu_install_redis.sh /install/ubuntu_install_redis.sh
RUN bash /install/ubuntu_install_redis.sh
# Golang environment
COPY install/ubuntu_install_golang.sh /install/ubuntu_install_golang.sh
RUN bash /install/ubuntu_install_golang.sh
# SGX deps (build early; changes infrequently)
COPY install/ubuntu_install_sgx.sh /install/ubuntu_install_sgx.sh
RUN bash /install/ubuntu_install_sgx.sh
ENV LD_LIBRARY_PATH /opt/sgxsdk/lib64:${LD_LIBRARY_PATH}
# Rust env
# Rust env (build early; takes a while)
COPY install/ubuntu_install_rust.sh /install/ubuntu_install_rust.sh
RUN bash /install/ubuntu_install_rust.sh
ENV RUSTUP_HOME /opt/rust
ENV CARGO_HOME /opt/rust
ENV RUSTC_WRAPPER sccache
# SGX deps
COPY install/ubuntu_install_sgx.sh /install/ubuntu_install_sgx.sh
RUN bash /install/ubuntu_install_sgx.sh
ENV LD_LIBRARY_PATH /opt/sgxsdk/lib64:${LD_LIBRARY_PATH}
# AutoTVM deps
COPY install/ubuntu_install_redis.sh /install/ubuntu_install_redis.sh
RUN bash /install/ubuntu_install_redis.sh
# 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
......@@ -7,9 +7,9 @@ curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path --default-toolchai
. $CARGO_HOME/env
rustup toolchain add nightly
rustup component add rust-src
cargo +nightly install sccache
cargo +nightly install rustfmt-nightly --version 0.99.5 --force
cargo +nightly install xargo
# make rust usable by all users
chmod a+w /opt/rust
sudo find /opt/rust -type d -exec chmod a+w {} \;
chmod -R a+w /opt/rust
......@@ -38,14 +38,14 @@ trailing_comma = "Vertical"
match_block_trailing_comma = false
blank_lines_upper_bound = 1
blank_lines_lower_bound = 0
edition = "Edition2015"
edition = "2015"
merge_derives = true
use_try_shorthand = true
use_field_init_shorthand = false
force_explicit_abi = true
condense_wildcard_suffixes = false
color = "Auto"
required_version = "0.99.4"
required_version = "0.99.5"
unstable_features = false
disable_all_formatting = false
skip_children = false
......
......@@ -173,7 +173,8 @@ impl<'a> Tensor<'a> {
expected_stride * (*shape as usize),
)
},
).0
)
.0
}
}
}
......
......@@ -56,11 +56,13 @@ impl Graph {
.as_ref()
.ok_or(ErrorKind::GraphFormatError(
"Missing graph attrs".to_string(),
))?.get(attr)
))?
.get(attr)
.ok_or(ErrorKind::GraphFormatError(format!(
"Missing {} attr",
attr
)))?.to_owned(),
)))?
.to_owned(),
)?)
}
}
......@@ -99,7 +101,8 @@ impl Node {
.ok_or(format!(
"Node `{}` is missing attrs.flatten_data",
self.name
))?.parse::<u8>()?
))?
.parse::<u8>()?
== 1;
Ok(NodeAttrs {
func_name,
......@@ -189,7 +192,8 @@ impl<'m, 't> GraphExecutor<'m, 't> {
} else {
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 mut storage_num_bytes = vec![0usize; *storage_ids.iter().max().unwrap_or(&1) + 1];
......@@ -216,7 +220,8 @@ impl<'m, 't> GraphExecutor<'m, 't> {
strides: None,
byte_offset: 0,
}
}).collect();
})
.collect();
Ok(tensors)
}
......@@ -261,7 +266,8 @@ impl<'m, 't> GraphExecutor<'m, 't> {
} else {
DLTensor::from(tensor)
})
}).collect::<Result<Vec<DLTensor>>>()
})
.collect::<Result<Vec<DLTensor>>>()
.unwrap();
let op: Box<Fn()> = box move || {
let args = dl_tensors
......
......@@ -58,7 +58,8 @@ impl Job {
},
cdata: self.cdata,
pending: Arc::clone(&self.pending),
}).collect()
})
.collect()
}
/// Waits for all tasks in this `Job` to be completed.
......@@ -110,7 +111,8 @@ impl<'a> Threads {
let (p, c) = bounded_spsc_queue::make(2);
let handle = thread::spawn(move || cb(c.into()));
(handle, p)
}).unzip();
})
.unzip();
Threads {
handles: handles,
queues: queues,
......@@ -128,7 +130,8 @@ impl<'a> Threads {
let (p, c) = bounded_spsc_queue::make(2);
consumer_queues.push_back(c.into());
p
}).collect();
})
.collect();
ocall_packed!("__sgx_thread_group_launch__", num_threads as u64);
Threads { queues: queues }
}
......
......@@ -20,7 +20,8 @@ fn test_load_graph() {
let graph = Graph::try_from(
&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!(
......
#!/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