ort-web 0.1.0+1.23

ONNX Runtime on the web 🌐 - An alternative backend for ort
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use alloc::string::String;

use wasm_bindgen::{JsCast, JsValue};

pub fn value_to_string(value: &JsValue) -> String {
	js_sys::Object::unchecked_from_js_ref(value).to_string().into()
}

pub fn num_elements(dims: &[i32]) -> usize {
	let mut size = 1usize;
	for dim in dims {
		if *dim < 0 {
			return 0;
		}
		size *= *dim as usize;
	}
	size
}