Skip to content

Commit

Permalink
feat: Added version for mnn
Browse files Browse the repository at this point in the history
  • Loading branch information
uttarayan21 committed Sep 11, 2024
1 parent 8ce72e7 commit 9217ebd
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ thiserror = "1.0"
error-stack = { version = "0.5" }
oneshot = "0.1"
tracing = { version = "0.1.40", optional = true }
semver = "1.0.23"

[features]
metal = ["mnn-sys/metal"]
Expand Down
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions mnn-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ crt_static = []

[dependencies]
libc = "0.2.155"
semver = "1.0.23"
1 change: 1 addition & 0 deletions mnn-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ pub fn mnn_c_bindgen(vendor: impl AsRef<Path>, out: impl AsRef<Path>) -> Result<
"tensor_c.h",
"backend_c.h",
"schedule_c.h",
"mnndefine.h",
];

let bindings = bindgen::Builder::default()
Expand Down
2 changes: 1 addition & 1 deletion mnn-sys/mnn_c/interpreter_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void modelPrintIO(const char *model) {
}
}

const char *getVersion() { return MNN::getVersion(); }
// const char *getVersion() { return MNN::getVersion(); }
Interpreter *Interpreter_createFromFile(const char *file) {
return reinterpret_cast<Interpreter *>(
MNN::Interpreter::createFromFile(file));
Expand Down
4 changes: 4 additions & 0 deletions mnn-sys/mnn_c/mnndefine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ifndef MNN_DEFINE_C
#define MNN_DEFINE_C
#include<MNN/MNNDefine.h>
#endif
8 changes: 8 additions & 0 deletions mnn-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,11 @@ impl halide_type_code_t {
unsafe { std::mem::transmute(code) }
}
}

pub const fn version() -> semver::Version {
semver::Version::new(
mnn_sys::MNN_VERSION_MAJOR as u64,
mnn_sys::MNN_VERSION_MINOR as u64,
mnn_sys::MNN_VERSION_PATCH as u64,
)
}
4 changes: 4 additions & 0 deletions src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ pub enum SessionMode {
ResizeFix = mnn_sys::SessionMode::Session_Resize_Fix,
}

pub const fn version() -> semver::Version {
mnn_sys::version()
}

impl SessionMode {
#[cfg(windows)]
fn to_mnn_sys(&self) -> i32 {
Expand Down

0 comments on commit 9217ebd

Please sign in to comment.