From 316a9a3b40a5b6c000e8b4944244b3974d4ceffe Mon Sep 17 00:00:00 2001 From: dante <45801863+alexander-camuto@users.noreply.github.com> Date: Thu, 4 Apr 2024 18:07:08 +0100 Subject: [PATCH] chore: update tract (#766) --- Cargo.lock | 258 +++++++++++++++++++------------------ Cargo.toml | 2 +- src/circuit/ops/layouts.rs | 15 +++ src/circuit/ops/poly.rs | 39 +++++- src/graph/model.rs | 32 ++--- src/graph/utilities.rs | 21 ++- src/tensor/mod.rs | 8 +- src/tensor/ops.rs | 26 ++++ 8 files changed, 249 insertions(+), 152 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2c0cbe685..78c4a9c8d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -112,7 +112,7 @@ checksum = "1a047897373be4bbb0224c1afdabca92648dc57a9c9ef6e7b0be3aff7a859c83" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -211,9 +211,9 @@ checksum = "d301b3b94cb4b2f23d7917810addbbaff90738e0ca2be692bd027e70d7e0330c" [[package]] name = "arc-swap" -version = "1.7.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b3d0060af21e8d11a926981cc00c6c1541aa91dd64b9f881985c3da1094425f" +checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" [[package]] name = "ark-bls12-377" @@ -463,7 +463,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -483,13 +483,13 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.78" +version = "0.1.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "461abc97219de0eaaf81fe3ef974a540158f3d079c2ab200f891f1a2ef201e85" +checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -522,20 +522,20 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] name = "autocfg" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "backtrace" -version = "0.3.70" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95d8e92cac0961e91dbd517496b00f7e9b92363dbe6d42c3198268323798860c" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ "addr2line", "cc", @@ -716,9 +716,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" dependencies = [ "serde", ] @@ -734,9 +734,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "694c8807f2ae16faecc43dc17d74b3eb042482789fd0eb64b39a2e04e087053f" +checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" dependencies = [ "serde", ] @@ -779,9 +779,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.35" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" +checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" dependencies = [ "android-tzdata", "iana-time-zone", @@ -814,9 +814,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.3" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "949626d00e063efc93b6dca932419ceb5432f99769911c0b995f7e884c778813" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" dependencies = [ "clap_builder", "clap_derive", @@ -836,14 +836,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.3" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90239a040c80f5e14809ca132ddc4176ab33d5e17e49691793296e3fcb34d72f" +checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -1177,9 +1177,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", "zeroize", @@ -1409,7 +1409,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -1575,7 +1575,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.53", + "syn 2.0.58", "toml", "walkdir", ] @@ -1593,7 +1593,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -1619,7 +1619,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.53", + "syn 2.0.58", "tempfile", "thiserror", "tiny-keccak", @@ -1772,7 +1772,7 @@ dependencies = [ "ark-std 0.3.0", "bincode", "chrono", - "clap 4.5.3", + "clap 4.5.4", "colored", "colored_json", "console_error_panic_hook", @@ -1837,9 +1837,9 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "fastrand" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" [[package]] name = "fastrlp" @@ -2028,7 +2028,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -2258,7 +2258,7 @@ dependencies = [ [[package]] name = "halo2curves" version = "0.3.2" -source = "git+https://github.com/privacy-scaling-explorations/halo2curves?tag=0.3.2#9f5c50810bbefe779ee5cf1d852b2fe85dc35d5e" +source = "git+https://github.com/privacy-scaling-explorations/halo2curves.git?tag=0.3.2#9f5c50810bbefe779ee5cf1d852b2fe85dc35d5e" dependencies = [ "ff", "group", @@ -2602,9 +2602,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "2.2.5" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -2626,9 +2626,9 @@ dependencies = [ [[package]] name = "indoc" -version = "2.0.4" +version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" +checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" [[package]] name = "inout" @@ -2699,11 +2699,20 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" @@ -2823,13 +2832,12 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libredox" -version = "0.0.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags 2.5.0", "libc", - "redox_syscall", ] [[package]] @@ -2877,7 +2885,7 @@ checksum = "fc2fb41a9bb4257a3803154bdf7e2df7d45197d1941c9b1a90ad815231630721" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -2962,24 +2970,24 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "memmap2" -version = "0.5.10" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" +checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" dependencies = [ "libc", ] [[package]] name = "memoffset" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ "autocfg", ] @@ -3187,7 +3195,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -3271,7 +3279,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -3291,9 +3299,9 @@ dependencies = [ [[package]] name = "openssl-sys" -version = "0.9.101" +version = "0.9.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" dependencies = [ "cc", "libc", @@ -3444,9 +3452,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.8" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f8023d0fb78c8e03784ea1c7f3fa36e68a723138990b8d5a47d916b651e7a8" +checksum = "311fb059dee1a7b802f036316d790138c613a4e8b180c822e3925a662e9f0c95" dependencies = [ "memchr", "thiserror", @@ -3455,9 +3463,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.8" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0d24f72393fd16ab6ac5738bc33cdb6a9aa73f8b902e8fe29cf4e67d7dd1026" +checksum = "f73541b156d32197eecda1a4014d7f868fd2bcb3c550d5386087cfba442bf69c" dependencies = [ "pest", "pest_generator", @@ -3465,22 +3473,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.8" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc17e2a6c7d0a492f0158d7a4bd66cc17280308bbaff78d5bef566dca35ab80" +checksum = "c35eeed0a3fab112f75165fdc026b3913f4183133f19b49be773ac9ea966e8bd" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] name = "pest_meta" -version = "2.7.8" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "934cd7631c050f4674352a6e835d5f6711ffbfb9345c2fc0107155ac495ae293" +checksum = "2adbf29bb9776f28caece835398781ab24435585fe0d4dc1374a61db5accedca" dependencies = [ "once_cell", "pest", @@ -3550,7 +3558,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -3588,14 +3596,14 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -3719,12 +3727,12 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "prettyplease" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" +checksum = "8d3928fb5db768cb86f891ff014f0144589297e3c6a1aba6ed7cecfdace270c7" dependencies = [ "proc-macro2", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -3933,7 +3941,7 @@ dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -3946,7 +3954,7 @@ dependencies = [ "proc-macro2", "pyo3-build-config", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -4049,9 +4057,9 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "rayon" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ "either", "rayon-core", @@ -4089,9 +4097,9 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", "libredox", @@ -4100,9 +4108,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.3" +version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick", "memchr", @@ -4123,9 +4131,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "remove_dir_all" @@ -4444,9 +4452,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.11.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ef2175c2907e7c8bc0a9c3f86aeb5ec1f3b275300ad58a44d0c3ae379a5e52e" +checksum = "788745a868b0e751750388f4e6546eb921ef714a4317fa6954f7cde114eb2eb7" dependencies = [ "cfg-if", "derive_more", @@ -4456,9 +4464,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.11.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b8eb8fd61c5cdd3390d9b2132300a7e7618955b98b8416f118c1b4e144f" +checksum = "7dc2f4e8bc344b9fc3d5f74f72c2e55bfc38d28dc2ebc69c194a3df424e4d9ac" dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", @@ -4524,9 +4532,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.9.2" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" dependencies = [ "bitflags 1.3.2", "core-foundation", @@ -4537,9 +4545,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" dependencies = [ "core-foundation-sys", "libc", @@ -4637,14 +4645,14 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" dependencies = [ "itoa", "ryu", @@ -4845,12 +4853,12 @@ checksum = "fe895eb47f22e2ddd4dabc02bce419d2e643c8e3b585c78158b349195bc24d82" [[package]] name = "string-interner" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e2531d8525b29b514d25e275a43581320d587b86db302b9a7e464bac579648" +checksum = "07f9fdfdd31a0ff38b59deb401be81b73913d76c9cc5b1aed4e1330a223420b9" dependencies = [ "cfg-if", - "hashbrown 0.11.2", + "hashbrown 0.14.3", "serde", ] @@ -4880,9 +4888,9 @@ dependencies = [ [[package]] name = "strsim" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" @@ -4903,7 +4911,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -4938,9 +4946,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.53" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", "quote", @@ -5113,7 +5121,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -5179,9 +5187,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.36.0" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", "bytes", @@ -5202,7 +5210,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -5337,7 +5345,7 @@ source = "git+https://github.com/zkonduit/enum_to_subcommand#42e9870f1f757932bab dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -5365,7 +5373,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -5389,8 +5397,8 @@ dependencies = [ [[package]] name = "tract-core" -version = "0.20.23-pre" -source = "git+https://github.com/sonos/tract/?rev=7b1aa33b2f7d1f19b80e270c83320f0f94daff69#7b1aa33b2f7d1f19b80e270c83320f0f94daff69" +version = "0.21.3" +source = "git+https://github.com/sonos/tract/?rev=681a096f02c9d7d363102d9fb0e446d1710ac2c8#681a096f02c9d7d363102d9fb0e446d1710ac2c8" dependencies = [ "anyhow", "bit-set", @@ -5413,12 +5421,12 @@ dependencies = [ [[package]] name = "tract-data" -version = "0.20.23-pre" -source = "git+https://github.com/sonos/tract/?rev=7b1aa33b2f7d1f19b80e270c83320f0f94daff69#7b1aa33b2f7d1f19b80e270c83320f0f94daff69" +version = "0.21.3" +source = "git+https://github.com/sonos/tract/?rev=681a096f02c9d7d363102d9fb0e446d1710ac2c8#681a096f02c9d7d363102d9fb0e446d1710ac2c8" dependencies = [ "anyhow", "half 2.2.1", - "itertools 0.10.5", + "itertools 0.12.1", "lazy_static", "maplit", "ndarray", @@ -5432,8 +5440,8 @@ dependencies = [ [[package]] name = "tract-hir" -version = "0.20.23-pre" -source = "git+https://github.com/sonos/tract/?rev=7b1aa33b2f7d1f19b80e270c83320f0f94daff69#7b1aa33b2f7d1f19b80e270c83320f0f94daff69" +version = "0.21.3" +source = "git+https://github.com/sonos/tract/?rev=681a096f02c9d7d363102d9fb0e446d1710ac2c8#681a096f02c9d7d363102d9fb0e446d1710ac2c8" dependencies = [ "derive-new", "log", @@ -5442,8 +5450,8 @@ dependencies = [ [[package]] name = "tract-linalg" -version = "0.20.23-pre" -source = "git+https://github.com/sonos/tract/?rev=7b1aa33b2f7d1f19b80e270c83320f0f94daff69#7b1aa33b2f7d1f19b80e270c83320f0f94daff69" +version = "0.21.3" +source = "git+https://github.com/sonos/tract/?rev=681a096f02c9d7d363102d9fb0e446d1710ac2c8#681a096f02c9d7d363102d9fb0e446d1710ac2c8" dependencies = [ "cc", "derive-new", @@ -5466,8 +5474,8 @@ dependencies = [ [[package]] name = "tract-nnef" -version = "0.20.23-pre" -source = "git+https://github.com/sonos/tract/?rev=7b1aa33b2f7d1f19b80e270c83320f0f94daff69#7b1aa33b2f7d1f19b80e270c83320f0f94daff69" +version = "0.21.3" +source = "git+https://github.com/sonos/tract/?rev=681a096f02c9d7d363102d9fb0e446d1710ac2c8#681a096f02c9d7d363102d9fb0e446d1710ac2c8" dependencies = [ "byteorder", "flate2", @@ -5480,8 +5488,8 @@ dependencies = [ [[package]] name = "tract-onnx" -version = "0.20.23-pre" -source = "git+https://github.com/sonos/tract/?rev=7b1aa33b2f7d1f19b80e270c83320f0f94daff69#7b1aa33b2f7d1f19b80e270c83320f0f94daff69" +version = "0.21.3" +source = "git+https://github.com/sonos/tract/?rev=681a096f02c9d7d363102d9fb0e446d1710ac2c8#681a096f02c9d7d363102d9fb0e446d1710ac2c8" dependencies = [ "bytes", "derive-new", @@ -5497,8 +5505,8 @@ dependencies = [ [[package]] name = "tract-onnx-opl" -version = "0.20.23-pre" -source = "git+https://github.com/sonos/tract/?rev=7b1aa33b2f7d1f19b80e270c83320f0f94daff69#7b1aa33b2f7d1f19b80e270c83320f0f94daff69" +version = "0.21.3" +source = "git+https://github.com/sonos/tract/?rev=681a096f02c9d7d363102d9fb0e446d1710ac2c8#681a096f02c9d7d363102d9fb0e446d1710ac2c8" dependencies = [ "getrandom", "log", @@ -5755,7 +5763,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", "wasm-bindgen-shared", ] @@ -5799,7 +5807,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5844,7 +5852,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -6154,7 +6162,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -6174,5 +6182,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] diff --git a/Cargo.toml b/Cargo.toml index d4b0cf247..a72adf788 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,7 +80,7 @@ pyo3-asyncio = { version = "0.20.0", features = [ "tokio-runtime", ], default_features = false, optional = true } pyo3-log = { version = "0.9.0", default_features = false, optional = true } -tract-onnx = { git = "https://github.com/sonos/tract/", rev = "7b1aa33b2f7d1f19b80e270c83320f0f94daff69", default_features = false, optional = true } +tract-onnx = { git = "https://github.com/sonos/tract/", rev = "681a096f02c9d7d363102d9fb0e446d1710ac2c8", default_features = false, optional = true } tabled = { version = "0.12.0", optional = true } diff --git a/src/circuit/ops/layouts.rs b/src/circuit/ops/layouts.rs index b7bad247e..0cdb314ff 100644 --- a/src/circuit/ops/layouts.rs +++ b/src/circuit/ops/layouts.rs @@ -1975,6 +1975,21 @@ pub(crate) fn pairwise( + config: &BaseConfig, + region: &mut RegionCtx, + values: &[ValTensor; 1], + axes: &[usize], +) -> Result, Box> { + let squared = pow(config, region, values, 2)?; + let sum_squared = sum_axes(config, region, &[squared], axes)?; + + let dividand: usize = values[0].len() / sum_squared.len(); + + let mean_squared = div(config, region, &[sum_squared], F::from(dividand as u64))?; + Ok(mean_squared) +} + /// expand the tensor to the given shape pub(crate) fn expand( config: &BaseConfig, diff --git a/src/circuit/ops/poly.rs b/src/circuit/ops/poly.rs index 241138938..b6a1ced27 100644 --- a/src/circuit/ops/poly.rs +++ b/src/circuit/ops/poly.rs @@ -1,6 +1,6 @@ use crate::{ circuit::layouts, - fieldutils::felt_to_i128, + fieldutils::{felt_to_i128, i128_to_felt}, tensor::{self, Tensor, TensorError}, }; @@ -62,6 +62,9 @@ pub enum PolyOp { Sum { axes: Vec, }, + MeanOfSquares { + axes: Vec, + }, Prod { axes: Vec, len_prod: usize, @@ -105,10 +108,28 @@ impl< fn as_string(&self) -> String { match &self { - PolyOp::GatherElements { dim, .. } => format!("GATHERELEMENTS (dim={})", dim), - PolyOp::GatherND { batch_dims, .. } => format!("GATHERND (batch_dims={})", batch_dims), - PolyOp::ScatterElements { dim, .. } => format!("SCATTERELEMENTS (dim={})", dim), - PolyOp::ScatterND { .. } => "SCATTERND".into(), + PolyOp::GatherElements { dim, constant_idx } => format!( + "GATHERELEMENTS (dim={}, constant_idx{})", + dim, + constant_idx.is_some() + ), + PolyOp::GatherND { + batch_dims, + indices, + } => format!( + "GATHERND (batch_dims={}, constant_idx{})", + batch_dims, + indices.is_some() + ), + PolyOp::MeanOfSquares { axes } => format!("MEANOFSQUARES (axes={:?})", axes), + PolyOp::ScatterElements { dim, constant_idx } => format!( + "SCATTERELEMENTS (dim={}, constant_idx{})", + dim, + constant_idx.is_some() + ), + PolyOp::ScatterND { constant_idx } => { + format!("SCATTERND (constant_idx={})", constant_idx.is_some()) + } PolyOp::MultiBroadcastTo { shape } => format!("MULTIBROADCASTTO (shape={:?})", shape), PolyOp::MoveAxis { .. } => "MOVEAXIS".into(), PolyOp::Downsample { .. } => "DOWNSAMPLE".into(), @@ -146,6 +167,10 @@ impl< fn f(&self, inputs: &[Tensor]) -> Result, TensorError> { let mut inputs = inputs.to_vec(); let res = match &self { + PolyOp::MeanOfSquares { axes } => { + let x = inputs[0].map(|x| felt_to_i128(x)); + Ok(tensor::ops::nonlinearities::mean_of_squares_axes(&x, axes).map(i128_to_felt)) + } PolyOp::MultiBroadcastTo { shape } => { if 1 != inputs.len() { return Err(TensorError::DimMismatch( @@ -292,6 +317,9 @@ impl< PolyOp::MultiBroadcastTo { shape } => { layouts::expand(config, region, values[..].try_into()?, shape)? } + PolyOp::MeanOfSquares { axes } => { + layouts::mean_of_squares_axes(config, region, values[..].try_into()?, axes)? + } PolyOp::Xor => layouts::xor(config, region, values[..].try_into()?)?, PolyOp::Or => layouts::or(config, region, values[..].try_into()?)?, PolyOp::And => layouts::and(config, region, values[..].try_into()?)?, @@ -404,6 +432,7 @@ impl< fn out_scale(&self, in_scales: Vec) -> Result> { let scale = match self { + PolyOp::MeanOfSquares { .. } => 2 * in_scales[0], PolyOp::Xor | PolyOp::Or | PolyOp::And | PolyOp::Not => 0, PolyOp::Iff => in_scales[1], PolyOp::Einsum { .. } => { diff --git a/src/graph/model.rs b/src/graph/model.rs index ec39d71f2..720d86bde 100644 --- a/src/graph/model.rs +++ b/src/graph/model.rs @@ -1200,6 +1200,20 @@ impl Model { .collect(); for (idx, node) in self.graph.nodes.iter() { + debug!("laying out {}: {}", idx, node.as_str(),); + // Then number of columns in the circuits + #[cfg(not(target_arch = "wasm32"))] + region.debug_report(); + debug!("input indices: {:?}", node.inputs()); + debug!("output scales: {:?}", node.out_scales()); + debug!( + "input scales: {:?}", + node.inputs() + .iter() + .map(|(idx, outlet)| self.graph.nodes[idx].out_scales()[*outlet]) + .collect_vec() + ); + let mut values: Vec> = if !node.is_input() { node.inputs() .iter() @@ -1211,25 +1225,11 @@ impl Model { // we re-assign inputs, always from the 0 outlet vec![results.get(idx).ok_or(GraphError::MissingResults)?[0].clone()] }; - - debug!("laying out {}: {}", idx, node.as_str(),); - // Then number of columns in the circuits - #[cfg(not(target_arch = "wasm32"))] - region.debug_report(); - debug!("dims: {:?}", node.out_dims()); + debug!("output dims: {:?}", node.out_dims()); debug!( - "input_dims {:?}", + "input dims {:?}", values.iter().map(|v| v.dims()).collect_vec() ); - debug!("output scales: {:?}", node.out_scales()); - debug!("input indices: {:?}", node.inputs()); - debug!( - "input scales: {:?}", - node.inputs() - .iter() - .map(|(idx, outlet)| self.graph.nodes[idx].out_scales()[*outlet]) - .collect_vec() - ); match &node { NodeType::Node(n) => { diff --git a/src/graph/utilities.rs b/src/graph/utilities.rs index 1909be32c..37cfeb9bf 100644 --- a/src/graph/utilities.rs +++ b/src/graph/utilities.rs @@ -509,7 +509,7 @@ pub fn new_op_from_onnx( // if param_visibility.is_public() { if let Some(c) = inputs[1].opkind().get_mutable_constant() { inputs[1].decrement_use(); - deleted_indices.push(inputs.len() - 1); + deleted_indices.push(1); op = SupportedOp::Linear(crate::circuit::ops::poly::PolyOp::ScatterND { constant_idx: Some(c.raw_values.map(|x| x as usize)), }) @@ -545,7 +545,7 @@ pub fn new_op_from_onnx( // if param_visibility.is_public() { if let Some(c) = inputs[1].opkind().get_mutable_constant() { inputs[1].decrement_use(); - deleted_indices.push(inputs.len() - 1); + deleted_indices.push(1); op = SupportedOp::Linear(crate::circuit::ops::poly::PolyOp::GatherND { batch_dims, indices: Some(c.raw_values.map(|x| x as usize)), @@ -582,7 +582,7 @@ pub fn new_op_from_onnx( // if param_visibility.is_public() { if let Some(c) = inputs[1].opkind().get_mutable_constant() { inputs[1].decrement_use(); - deleted_indices.push(inputs.len() - 1); + deleted_indices.push(1); op = SupportedOp::Linear(crate::circuit::ops::poly::PolyOp::GatherElements { dim: axis, constant_idx: Some(c.raw_values.map(|x| x as usize)), @@ -734,6 +734,19 @@ pub fn new_op_from_onnx( SupportedOp::Linear(PolyOp::Sum { axes }) } + "Reduce" => { + if inputs.len() != 1 { + return Err(Box::new(GraphError::InvalidDims( + idx, + "mean of squares".to_string(), + ))); + }; + let op = load_op::(node.op(), idx, node.op().name().to_string())?; + let axes = op.axes.into_iter().collect(); + + SupportedOp::Linear(PolyOp::MeanOfSquares { axes }) + } + "Max" => { // Extract the max value // first find the input that is a constant @@ -1165,7 +1178,7 @@ pub fn new_op_from_onnx( // if param_visibility.is_public() { if let Some(c) = inputs[1].opkind().get_mutable_constant() { inputs[1].decrement_use(); - deleted_indices.push(inputs.len() - 1); + deleted_indices.push(1); if c.raw_values.len() > 1 { unimplemented!("only support scalar pow") } diff --git a/src/tensor/mod.rs b/src/tensor/mod.rs index f10500309..f9dd5a106 100644 --- a/src/tensor/mod.rs +++ b/src/tensor/mod.rs @@ -934,6 +934,7 @@ impl Tensor { pub fn move_axis(&mut self, source: usize, destination: usize) -> Result { assert!(source < self.dims.len()); assert!(destination < self.dims.len()); + let mut new_dims = self.dims.clone(); new_dims.remove(source); new_dims.insert(destination, self.dims[source]); @@ -965,6 +966,8 @@ impl Tensor { old_coord[source - 1] = *c; } else if (i < source && source < destination) || (i < destination && source > destination) + || (i > source && source > destination) + || (i > destination && source < destination) { old_coord[i] = *c; } else if i > source && source < destination { @@ -977,7 +980,10 @@ impl Tensor { )); } } - output.set(&coord, self.get(&old_coord)); + + let value = self.get(&old_coord); + + output.set(&coord, value); } Ok(output) diff --git a/src/tensor/ops.rs b/src/tensor/ops.rs index f5f1c98ae..f66f4f9bc 100644 --- a/src/tensor/ops.rs +++ b/src/tensor/ops.rs @@ -4404,6 +4404,32 @@ pub mod nonlinearities { let sum = sum(a).unwrap(); const_div(&sum, (scale * a.len()) as f64) } + + /// Mean of squares axes + /// # Arguments + /// * `a` - Tensor + /// * `axis` - [usize] + /// # Examples + /// ``` + /// use ezkl::tensor::Tensor; + /// use ezkl::tensor::ops::nonlinearities::mean_of_squares_axes; + /// let x = Tensor::::new( + /// Some(&[2, 15, 2, 1, 1, 0]), + /// &[2, 3], + /// ).unwrap(); + /// let result = mean_of_squares_axes(&x, &[1]); + /// let expected = Tensor::::new( + /// Some(&[78, 1]), + /// &[2, 1], + /// ).unwrap(); + /// assert_eq!(result, expected); + /// ``` + pub fn mean_of_squares_axes(a: &Tensor, axes: &[usize]) -> Tensor { + let square = a.map(|a_i| a_i * a_i); + let sum = sum_axes(&square, axes).unwrap(); + let denominator = a.len() / sum.len(); + const_div(&sum, denominator as f64) + } } /// Ops that return the transcript i.e intermediate calcs of an op