Skip to content

Commit

Permalink
Add rust to ci
Browse files Browse the repository at this point in the history
  • Loading branch information
nhynes committed Oct 6, 2018
1 parent ed66d49 commit c80c4fc
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 13 deletions.
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions rust/.rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion rust/src/runtime/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ impl<'a> Tensor<'a> {
expected_stride * (*shape as usize),
)
},
).0
)
.0
}
}
}
Expand Down
18 changes: 12 additions & 6 deletions rust/src/runtime/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)?)
}
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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];
Expand All @@ -216,7 +220,8 @@ impl<'m, 't> GraphExecutor<'m, 't> {
strides: None,
byte_offset: 0,
}
}).collect();
})
.collect();

Ok(tensors)
}
Expand Down Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions rust/src/runtime/threading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand All @@ -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 }
}
Expand Down
3 changes: 2 additions & 1 deletion rust/tests/test_graph_serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
22 changes: 22 additions & 0 deletions tests/scripts/task_rust.sh
Original file line number Diff line number Diff line change
@@ -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 -

0 comments on commit c80c4fc

Please sign in to comment.