Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emscripten support fixes #1220

Merged
merged 2 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions onnx/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,10 @@ impl Framework<pb::ModelProto, InferenceModel> for Onnx {
fn proto_model_for_path(&self, p: impl AsRef<path::Path>) -> TractResult<pb::ModelProto> {
let p = p.as_ref();
let mut file = fs::File::open(p).with_context(|| format!("Opening {p:?}"))?;
Ok(self.proto_model_for_read(&mut file)?)
Ok(self.proto_model_for_read(&mut file)?)
}

#[cfg(any(windows, unix))]
#[cfg(all(any(windows, unix), not(target_os = "emscripten")))]
fn proto_model_for_path(&self, p: impl AsRef<path::Path>) -> TractResult<pb::ModelProto> {
let p = p.as_ref();
let map = unsafe { memmap2::Mmap::map(&fs::File::open(p).with_context(|| format!("Opening {p:?}"))?)? };
Expand Down
4 changes: 2 additions & 2 deletions onnx/src/tensor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ fn extend_bytes_from_path(buf: &mut Vec<u8>, p: impl AsRef<Path>) -> TractResult
while reader.fill_buf()?.len() > 0 {
buf.extend_from_slice(reader.buffer());
reader.consume(reader.buffer().len());
}
}
Ok(())
}

#[cfg(any(windows, unix))]
#[cfg(all(any(windows, unix), not(target_os = "emscripten")))]
fn extend_bytes_from_path(buf: &mut Vec<u8>, p: impl AsRef<Path>) -> TractResult<()> {
let file = fs::File::open(p)?;
let mmap = unsafe { memmap2::Mmap::map(&file)? };
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl Tensorflow {
Ok(GraphDef::decode(b)?)
}

#[cfg(any(windows, unix))]
#[cfg(all(any(windows, unix), not(target_os = "emscripten")))]
pub fn read_frozen_from_path(&self, p: impl AsRef<path::Path>) -> TractResult<GraphDef> {
let map = unsafe { memmap2::Mmap::map(&fs::File::open(p)?)? };
Ok(GraphDef::decode(&*map)?)
Expand Down
Loading