diff --git a/Jenkinsfile b/Jenkinsfile index e12ff3558ed1a..f63e7d0f396eb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -139,6 +139,7 @@ stage('Build') { timeout(time: max_time, unit: 'MINUTES') { sh "${docker_run} tvmai/ci-cpu ./tests/scripts/task_cpp_unittest.sh" sh "${docker_run} tvmai/ci-cpu ./tests/scripts/task_python_vta.sh" + sh "${docker_run} tvmai/ci-cpu ./tests/scripts/task_rust.sh" } } } diff --git a/docker/install/ubuntu_install_rust.sh b/docker/install/ubuntu_install_rust.sh index 1d17b66164c97..836186e8ff963 100644 --- a/docker/install/ubuntu_install_rust.sh +++ b/docker/install/ubuntu_install_rust.sh @@ -4,6 +4,7 @@ curl -sSo rustup.sh 'https://sh.rustup.rs' # rustc nightly-2018-08-25 is the version supported by the above version of rust-sgx-sdk bash rustup.sh -y --no-modify-path --default-toolchain nightly-2018-08-25 . $HOME/.cargo/env +rustup toolchain add nightly rustup component add rust-src -cargo install rustfmt-nightly --force -cargo install xargo +cargo +nightly install rustfmt-nightly --version 0.99.5 --force +cargo +nightly install xargo diff --git a/rust/.rustfmt.toml b/rust/.rustfmt.toml index df9a65dacfaa0..dbf3347a32bd4 100644 --- a/rust/.rustfmt.toml +++ b/rust/.rustfmt.toml @@ -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 diff --git a/rust/src/runtime/array.rs b/rust/src/runtime/array.rs index 79d22e400cff9..9d0941811758e 100644 --- a/rust/src/runtime/array.rs +++ b/rust/src/runtime/array.rs @@ -173,7 +173,8 @@ impl<'a> Tensor<'a> { expected_stride * (*shape as usize), ) }, - ).0 + ) + .0 } } } diff --git a/rust/src/runtime/graph.rs b/rust/src/runtime/graph.rs index 6c53aeb9f6e9e..08fbd59383804 100644 --- a/rust/src/runtime/graph.rs +++ b/rust/src/runtime/graph.rs @@ -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::()? + ))? + .parse::()? == 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::>>()?; + }) + .collect::>>()?; 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::>>() + }) + .collect::>>() .unwrap(); let op: Box = box move || { let args = dl_tensors diff --git a/rust/src/runtime/threading.rs b/rust/src/runtime/threading.rs index c0d6221c91b7a..693ebf7c4a335 100644 --- a/rust/src/runtime/threading.rs +++ b/rust/src/runtime/threading.rs @@ -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 } } diff --git a/rust/tests/test_graph_serde.rs b/rust/tests/test_graph_serde.rs index a596544212ca2..b02c128897942 100644 --- a/rust/tests/test_graph_serde.rs +++ b/rust/tests/test_graph_serde.rs @@ -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!( diff --git a/tests/scripts/task_rust.sh b/tests/scripts/task_rust.sh new file mode 100644 index 0000000000000..69a39b41f12b9 --- /dev/null +++ b/tests/scripts/task_rust.sh @@ -0,0 +1,22 @@ +#!/bin/bash +export LD_LIBRARY_PATH=lib:${LD_LIBRARY_PATH} +export PYTHONPATH=python:nnvm/python:topi/python + +set -e + +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 -