1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//! Convenience macros for building inference input maps.
//!
//! Provides an `inputs!` macro compatible with the `ort` 2.x API surface,
//! allowing callers to construct a `HashMap<&str, Tensor>` wrapped in a `Result`
//! using the same `"name" => tensor` syntax.
/// Build a `Result<HashMap<&str, Tensor>, OnnxError>` input map.
///
/// Compatible with the `ort` 2.x `inputs!` macro pattern used throughout
/// the COOLJAPAN ecosystem (torsh, oxigdal, oxify).
///
/// # Examples
///
/// ```
/// use oxionnx::{inputs, Tensor};
///
/// let t = Tensor::new(vec![1.0, 2.0, 3.0], vec![1, 3]);
/// let map = inputs!["input_ids" => t].expect("build inputs");
/// assert_eq!(map.len(), 1);
/// ```
///
/// Multiple inputs:
///
/// ```
/// use oxionnx::{inputs, Tensor};
///
/// let a = Tensor::zeros(&[1, 4]);
/// let b = Tensor::zeros(&[1, 4]);
/// let map = inputs!["q" => a, "k" => b].expect("build inputs");
/// assert_eq!(map.len(), 2);
/// ```
/// Build a typed input map for use with [`crate::Session::run_typed`].
///
/// Each value must be a [`crate::TypedTensor`]. Returns a
/// `Result<HashMap<&str, TypedTensor>, OnnxError>` for consistency with
/// the `inputs!` macro.
///
/// # Example
///
/// ```ignore
/// let map = inputs_typed!("input_ids" => TypedTensor::new(TensorStorage::I64(ids), vec![1, 32]))?;
/// ```