From ae5e543bc698930ef808e82addb4ce72e81954c4 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 2 Apr 2021 16:14:04 -0700 Subject: [PATCH 1/3] Specify input layout (i.e. NHWC) explicitly in tests Due to a change in the behavior of the upstream [`SetBlob`]( https://github.com/openvinotoolkit/openvino/pull/2402/files#diff-0ec2c2a8d308ceb06e9f0d16319099aa1bb461c49a19e51c5267ced413f25f77R278-R280), `infer_request.set_blob` would fail with a `GeneralError`. In tracking this down, it appears that the blob validation expects the "blocking descriptions" to match. In these tests, we import NHWC tensors so we must now explicitly set this as the input layout. --- crates/openvino/tests/classify-alexnet.rs | 3 ++- crates/openvino/tests/classify-inception.rs | 3 ++- crates/openvino/tests/classify-mobilenet.rs | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/openvino/tests/classify-alexnet.rs b/crates/openvino/tests/classify-alexnet.rs index b4be39e..decfece 100644 --- a/crates/openvino/tests/classify-alexnet.rs +++ b/crates/openvino/tests/classify-alexnet.rs @@ -11,7 +11,7 @@ use util::{Prediction, Predictions}; #[test] fn classify_alexnet() { let mut core = Core::new(None).unwrap(); - let network = core + let mut network = core .read_network_from_file( &Fixture::graph().to_string_lossy(), &Fixture::weights().to_string_lossy(), @@ -20,6 +20,7 @@ fn classify_alexnet() { let input_name = &network.get_input_name(0).unwrap(); assert_eq!(input_name, "data"); + network.set_input_layout(input_name, Layout::NHWC).unwrap(); let output_name = &network.get_output_name(0).unwrap(); assert_eq!(output_name, "prob"); diff --git a/crates/openvino/tests/classify-inception.rs b/crates/openvino/tests/classify-inception.rs index fbafb51..3478b71 100644 --- a/crates/openvino/tests/classify-inception.rs +++ b/crates/openvino/tests/classify-inception.rs @@ -11,7 +11,7 @@ use util::{Prediction, Predictions}; #[test] fn classify_inception() { let mut core = Core::new(None).unwrap(); - let network = core + let mut network = core .read_network_from_file( &Fixture::graph().to_string_lossy(), &Fixture::weights().to_string_lossy(), @@ -20,6 +20,7 @@ fn classify_inception() { let input_name = &network.get_input_name(0).unwrap(); assert_eq!(input_name, "input"); + network.set_input_layout(input_name, Layout::NHWC).unwrap(); let output_name = &network.get_output_name(0).unwrap(); assert_eq!(output_name, "InceptionV3/Predictions/Softmax"); diff --git a/crates/openvino/tests/classify-mobilenet.rs b/crates/openvino/tests/classify-mobilenet.rs index 8a8d8ec..77a1c7a 100644 --- a/crates/openvino/tests/classify-mobilenet.rs +++ b/crates/openvino/tests/classify-mobilenet.rs @@ -12,7 +12,7 @@ use util::{Prediction, Predictions}; #[test] fn classify_mobilenet() { let mut core = Core::new(None).unwrap(); - let network = core + let mut network = core .read_network_from_file( &Fixture::graph().to_string_lossy(), &Fixture::weights().to_string_lossy(), @@ -21,6 +21,7 @@ fn classify_mobilenet() { let input_name = &network.get_input_name(0).unwrap(); assert_eq!(input_name, "input"); + network.set_input_layout(input_name, Layout::NHWC).unwrap(); let output_name = &network.get_output_name(0).unwrap(); assert_eq!(output_name, "MobilenetV2/Predictions/Reshape_1"); From afeccbd420350ebf502cb12c84c65bee78c61d5d Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 29 Mar 2021 16:09:37 -0700 Subject: [PATCH 2/3] Do not build openvino-tensor-converter in workspace --- .github/workflows/main.yml | 18 + Cargo.lock | 210 --------- Cargo.toml | 2 +- crates/openvino-tensor-converter/Cargo.lock | 485 ++++++++++++++++++++ crates/openvino-tensor-converter/Cargo.toml | 7 + 5 files changed, 511 insertions(+), 211 deletions(-) create mode 100644 crates/openvino-tensor-converter/Cargo.lock diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5ad5fd3..2d13429 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -49,3 +49,21 @@ jobs: run: git lfs checkout - name: Build the Docker image run: docker build . --tag openvino-rs:$(date +%s) + + converter: + name: Build and test the openvino-tensor-converter tool + runs-on: ubuntu-latest + defaults: + run: + working-directory: crates/openvino-tensor-converter + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Install OpenCV + run: sudo apt update && sudo apt install libopencv-dev libopencv-core4.2 + - name: Build + run: cargo build -v + - name: test + run: cargo test -v + diff --git a/Cargo.lock b/Cargo.lock index 19947b3..d8655cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -70,9 +70,6 @@ name = "cc" version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "66120af515773fb005778dc07c261bd201ec8ce50bd6e7144c927753fe013381" -dependencies = [ - "jobserver", -] [[package]] name = "cexpr" @@ -89,16 +86,6 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -[[package]] -name = "clang" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34c6913be3a1c94f52fb975cdec7ef5a7b69de10a55de66dcbc30d7046b85fa1" -dependencies = [ - "clang-sys", - "libc", -] - [[package]] name = "clang-sys" version = "1.0.0" @@ -134,12 +121,6 @@ dependencies = [ "cc", ] -[[package]] -name = "dunce" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2641c4a7c0c4101df53ea572bffdc561c146f6c2eb09e4df02bc4811e3feeb4" - [[package]] name = "env_logger" version = "0.7.1" @@ -168,15 +149,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" -[[package]] -name = "heck" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "hermit-abi" version = "0.1.15" @@ -195,15 +167,6 @@ dependencies = [ "quick-error", ] -[[package]] -name = "jobserver" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c71313ebb9439f74b00d9d2dcec36440beaf57a6aa0623068441dd7cd81a7f2" -dependencies = [ - "libc", -] - [[package]] name = "lazy_static" version = "1.4.0" @@ -241,12 +204,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "maplit" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" - [[package]] name = "memchr" version = "2.3.3" @@ -272,48 +229,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "once_cell" -version = "1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" - -[[package]] -name = "opencv" -version = "0.49.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7af7570b5a4cc0a6cbc003a46bbe7cf586bc01d4024442bcf735d56d5007394b" -dependencies = [ - "cc", - "clang", - "dunce", - "glob", - "jobserver", - "libc", - "num-traits", - "once_cell", - "opencv-binding-generator", - "pkg-config", - "semver", - "shlex", - "vcpkg", -] - -[[package]] -name = "opencv-binding-generator" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b103afeab0c96624c28ced967ad96601601717c1a0a5bbe03ddb6efbb9a7e50b" -dependencies = [ - "clang", - "clang-sys", - "dunce", - "maplit", - "once_cell", - "percent-encoding", - "regex", -] - [[package]] name = "openvino" version = "0.1.8" @@ -331,77 +246,12 @@ dependencies = [ "cmake", ] -[[package]] -name = "openvino-tensor-converter" -version = "0.1.0" -dependencies = [ - "log", - "opencv", - "pretty_env_logger", - "structopt", -] - [[package]] name = "peeking_take_while" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" -[[package]] -name = "percent-encoding" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" - -[[package]] -name = "pest" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" -dependencies = [ - "ucd-trie", -] - -[[package]] -name = "pkg-config" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" - -[[package]] -name = "pretty_env_logger" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "926d36b9553851b8b0005f1275891b392ee4d2d833852c417ed025477350fb9d" -dependencies = [ - "env_logger", - "log", -] - -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" version = "1.0.20" @@ -450,24 +300,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "semver" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" -dependencies = [ - "pest", -] - [[package]] name = "shlex" version = "0.1.1" @@ -480,30 +312,6 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" -[[package]] -name = "structopt" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5277acd7ee46e63e5168a80734c9f6ee81b1367a7d8772a2d765df2a3705d28c" -dependencies = [ - "clap", - "lazy_static", - "structopt-derive", -] - -[[package]] -name = "structopt-derive" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ba9cdfda491b814720b6b06e0cac513d922fc407582032e8706e9f137976f90" -dependencies = [ - "heck", - "proc-macro-error", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "syn" version = "1.0.39" @@ -562,18 +370,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "ucd-trie" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" - -[[package]] -name = "unicode-segmentation" -version = "1.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" - [[package]] name = "unicode-width" version = "0.1.8" @@ -586,12 +382,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" -[[package]] -name = "vcpkg" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" - [[package]] name = "vec_map" version = "0.8.2" diff --git a/Cargo.toml b/Cargo.toml index 7c3aec7..3a3d8cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,2 +1,2 @@ [workspace] -members = ["crates/openvino", "crates/openvino-sys", "crates/openvino-tensor-converter"] +members = ["crates/openvino", "crates/openvino-sys"] diff --git a/crates/openvino-tensor-converter/Cargo.lock b/crates/openvino-tensor-converter/Cargo.lock new file mode 100644 index 0000000..53f1a91 --- /dev/null +++ b/crates/openvino-tensor-converter/Cargo.lock @@ -0,0 +1,485 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "aho-corasick" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" +dependencies = [ + "memchr", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "cc" +version = "1.0.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" +dependencies = [ + "jobserver", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clang" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34c6913be3a1c94f52fb975cdec7ef5a7b69de10a55de66dcbc30d7046b85fa1" +dependencies = [ + "clang-sys", + "libc", +] + +[[package]] +name = "clang-sys" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f54d78e30b388d4815220c8dd03fea5656b6c6d32adb59e89061552a102f8da1" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "clap" +version = "2.33.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +dependencies = [ + "bitflags", + "textwrap", + "unicode-width", +] + +[[package]] +name = "dunce" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2641c4a7c0c4101df53ea572bffdc561c146f6c2eb09e4df02bc4811e3feeb4" + +[[package]] +name = "env_logger" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + +[[package]] +name = "heck" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +dependencies = [ + "libc", +] + +[[package]] +name = "humantime" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" +dependencies = [ + "quick-error", +] + +[[package]] +name = "jobserver" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c71313ebb9439f74b00d9d2dcec36440beaf57a6aa0623068441dd7cd81a7f2" +dependencies = [ + "libc", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8916b1f6ca17130ec6568feccee27c156ad12037880833a3b842a823236502e7" + +[[package]] +name = "libloading" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f84d96438c15fcd6c3f244c8fce01d1e2b9c6b5623e9c711dc9286d8fc92d6a" +dependencies = [ + "cfg-if", + "winapi", +] + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + +[[package]] +name = "memchr" +version = "2.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" + +[[package]] +name = "opencv" +version = "0.49.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7af7570b5a4cc0a6cbc003a46bbe7cf586bc01d4024442bcf735d56d5007394b" +dependencies = [ + "cc", + "clang", + "dunce", + "glob", + "jobserver", + "libc", + "num-traits", + "once_cell", + "opencv-binding-generator", + "pkg-config", + "semver", + "shlex", + "vcpkg", +] + +[[package]] +name = "opencv-binding-generator" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b103afeab0c96624c28ced967ad96601601717c1a0a5bbe03ddb6efbb9a7e50b" +dependencies = [ + "clang", + "clang-sys", + "dunce", + "maplit", + "once_cell", + "percent-encoding", + "regex", +] + +[[package]] +name = "openvino-tensor-converter" +version = "0.1.0" +dependencies = [ + "log", + "opencv", + "pretty_env_logger", + "structopt", +] + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + +[[package]] +name = "pkg-config" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" + +[[package]] +name = "pretty_env_logger" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "926d36b9553851b8b0005f1275891b392ee4d2d833852c417ed025477350fb9d" +dependencies = [ + "env_logger", + "log", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex" +version = "1.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + +[[package]] +name = "shlex" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" + +[[package]] +name = "structopt" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5277acd7ee46e63e5168a80734c9f6ee81b1367a7d8772a2d765df2a3705d28c" +dependencies = [ + "clap", + "lazy_static", + "structopt-derive", +] + +[[package]] +name = "structopt-derive" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ba9cdfda491b814720b6b06e0cac513d922fc407582032e8706e9f137976f90" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "syn" +version = "1.0.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6498a9efc342871f91cc2d0d694c674368b4ceb40f62b65a7a08c3792935e702" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "termcolor" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "ucd-trie" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + +[[package]] +name = "unicode-segmentation" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" + +[[package]] +name = "unicode-width" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "vcpkg" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" + +[[package]] +name = "version_check" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/crates/openvino-tensor-converter/Cargo.toml b/crates/openvino-tensor-converter/Cargo.toml index 9c8f406..e384585 100644 --- a/crates/openvino-tensor-converter/Cargo.toml +++ b/crates/openvino-tensor-converter/Cargo.toml @@ -12,3 +12,10 @@ structopt = { version = "0.3", default-features = false } # Note: by default this will attempt to find a 4.x version of OpenCV libraries (e.g. # `libopencv-dev`). opencv = {version = "0.49", default-features = false, features = ["opencv-4", "buildtime-bindgen", "clang-runtime"]} + +[features] +"opencv-32" = ["opencv/opencv-32"] + +# Do not include this tool in the default build; the OpenCV dependency is too fragile in different +# OS environments for this to build reliably. +[workspace] From 367b777590b45f3d6e61180cf31240eb3053183f Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 29 Mar 2021 16:47:48 -0700 Subject: [PATCH 3/3] Make CI run multiple combinations of OS and OpenVINO versions --- .github/workflows/main.yml | 29 +++++++++++++++++++------- Dockerfile | 42 +++++++++++++++----------------------- README.md | 3 ++- 3 files changed, 40 insertions(+), 34 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2d13429..e88e3d4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,9 +19,11 @@ jobs: submodules: true - run: rustup component add rustfmt - run: cargo fmt --all -- --check + - run: cd crates/openvino-tensor-converter && cargo fmt --all -- --check - build: - name: Build from OpenVINO source + # Build and test from the git-submodule-included OpenVINO source code. + source: + name: From source runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 @@ -31,15 +33,25 @@ jobs: - name: Checkout LFS obects run: git lfs checkout - name: Install system dependencies - run: sudo apt update && sudo apt install -y clang cmake libclang-dev gnupg2 libdrm2 libglib2.0-0 libusb-1.0-0-dev lsb-release libgtk-3-0 libtool libopencv-dev libopencv-core4.2 udev unzip dos2unix + run: sudo apt update && sudo apt install -y clang cmake libclang-dev gnupg2 libdrm2 libglib2.0-0 libusb-1.0-0-dev lsb-release libgtk-3-0 libtool udev unzip dos2unix - name: Build (openvino-sys from source) run: cargo build --verbose - name: Run tests run: cargo test --verbose + # Build and test from an existing OpenVINO installation inside a Docker image (i.e. download the + # binaries, then compile against these). docker: - name: Build from OpenVINO installation inside a Docker image + name: From binaries runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + os: [ubuntu18, ubuntu20] + version: [2020.4, 2021.1, 2021.2, 2021.3] + exclude: + - os: ubuntu20 + version: 2020.4 steps: - uses: actions/checkout@v2 with: @@ -48,10 +60,13 @@ jobs: - name: Checkout LFS obects run: git lfs checkout - name: Build the Docker image - run: docker build . --tag openvino-rs:$(date +%s) + run: docker build . --tag openvino-rs:${{ matrix.OS }}-${{ matrix.version }}-$(date +%s) --build-arg OS=${{ matrix.os }} --build-arg VERSION=${{ matrix.version }} + # Build and test the openvino-tensor-converter tool separately from the regular library builds; + # the OpenCV dependency is a bit fragile so the crate is not included by the default workspace + # commands. converter: - name: Build and test the openvino-tensor-converter tool + name: Converter tool runs-on: ubuntu-latest defaults: run: @@ -61,7 +76,7 @@ jobs: with: submodules: recursive - name: Install OpenCV - run: sudo apt update && sudo apt install libopencv-dev libopencv-core4.2 + run: sudo apt update && sudo apt install libclang-dev libopencv-dev libopencv-core4.2 - name: Build run: cargo build -v - name: test diff --git a/Dockerfile b/Dockerfile index a944efa..eb00818 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,28 @@ -# This Dockerfile demonstrates how to build the openvino bindings using an installation of OpenVINO. For instructions -# to install OpenVINO see the OpenVINO documentation, e.g. +# This Dockerfile demonstrates how to build the openvino bindings using an installation of OpenVINO. +# For instructions to install OpenVINO see the OpenVINO documentation, e.g. # https://docs.openvinotoolkit.org/latest/openvino_docs_install_guides_installing_openvino_apt.html. -FROM rust:1.50 +ARG OS=ubuntu18 +ARG VERSION=2020.4 +FROM openvino/${OS}_runtime:${VERSION} AS builder -# Setup Rust. -RUN rustup component add rustfmt +# OpenVINO's images use a default user, `openvino`, that disallows root access. +USER root -# Install OpenVINO. -WORKDIR /tmp -RUN wget https://apt.repos.intel.com/openvino/2020/GPG-PUB-KEY-INTEL-OPENVINO-2020 && \ - echo '5f5cff8a2d26ba7de91942bd0540fa4d GPG-PUB-KEY-INTEL-OPENVINO-2020' > CHECKSUM && \ - md5sum --check CHECKSUM && \ - apt-key add GPG-PUB-KEY-INTEL-OPENVINO-2020 && \ - echo "deb https://apt.repos.intel.com/openvino/2020 all main" | tee /etc/apt/sources.list.d/intel-openvino-2020.list && \ - apt update && \ - apt install -y intel-openvino-runtime-ubuntu18-2020.4.287 +# Install Rust. +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal +ENV PATH=/root/.cargo/bin:$PATH +RUN rustup component add rustfmt # Install build dependencies (for bindgen). -RUN apt install -y clang libclang-dev +RUN apt update && apt install -y clang libclang-dev -# Install OpenCV (for openvino-tensor-converter). -RUN apt install -y libopencv-dev libopencv-core3.2 - -# Copy in OpenVINO source -WORKDIR /usr/src/openvino +# Copy in source code. +WORKDIR /usr/src/openvino-rs COPY . . -# Hack to allow the opencv crate to build with an older version of the OpenCV libraries (FIXME). -RUN sed -i 's/"opencv-4"/"opencv-32"/g' crates/openvino-tensor-converter/Cargo.toml - # Build openvino libraries. -WORKDIR /usr/src/openvino/inference-engine/ie_bridges/rust RUN OPENVINO_INSTALL_DIR=/opt/intel/openvino cargo build -vv -# Test; note that we need to setup the library paths before using them since the OPENVINO_INSTALL_DIR can only affect -# the build library search path. +# Test; note that we need to setup the library paths before using them since the +# OPENVINO_INSTALL_DIR can only affect the build library search path. RUN ["/bin/bash", "-c", "source /opt/intel/openvino/bin/setupvars.sh && OPENVINO_INSTALL_DIR=/opt/intel/openvino cargo test -v"] diff --git a/README.md b/README.md index 5b73a4f..e4b4866 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,8 @@ cargo test ``` [openvino] and [openvino-sys] can also be built directly from OpenVINO™'s source code using CMake. -This build process can be quite slow and there are quite a few dependencies. Some notes: +This is not tested across all OS and OpenVINO™ versions--use at your own risk! Also, this build +process can be quite slow and there are quite a few dependencies. Some notes: - first, install the necessary packages to build OpenVINO™; steps are included in the [CI workflow](.github/workflows) but reference the [OpenVINO™ build documentation](https://github.com/openvinotoolkit/openvino/blob/master/build-instruction.md)