Skip to content

Commit

Permalink
fix doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
decahedron1 committed Feb 1, 2025
1 parent 6f57387 commit 77f7a9f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl Session {
/// dynamically.
///
/// ```
/// # use alloc::sync::Arc;
/// # use std::sync::Arc;
/// # use ort::{session::{run_options::RunOptions, Session}, tensor::TensorElementType, value::{Value, ValueType, TensorRef}};
/// # fn main() -> ort::Result<()> {
/// let session = Session::builder()?.commit_from_file("tests/data/upsample.onnx")?;
Expand Down Expand Up @@ -215,7 +215,7 @@ impl Session {
///
/// ```no_run
/// # // no_run because upsample.onnx is too simple of a model for the termination signal to be reliable enough
/// # use alloc::sync::Arc;
/// # use std::sync::Arc;
/// # use ort::{session::{Session, run_options::RunOptions}, value::{Value, ValueType, TensorRef}, tensor::TensorElementType};
/// # fn main() -> ort::Result<()> {
/// # let session = Session::builder()?.commit_from_file("tests/data/upsample.onnx")?;
Expand Down Expand Up @@ -343,7 +343,7 @@ impl Session {
/// dynamically.
///
/// ```
/// # use alloc::sync::Arc;
/// # use std::sync::Arc;
/// # use ort::{session::{Session, run_options::RunOptions}, value::{Value, ValueType, TensorRef}, tensor::TensorElementType};
/// # fn main() -> ort::Result<()> { tokio_test::block_on(async {
/// let session = Session::builder()?.with_intra_threads(2)?.commit_from_file("tests/data/upsample.onnx")?;
Expand Down Expand Up @@ -480,7 +480,7 @@ impl Session {
/// efficiency.
///
/// ```
/// # use alloc::sync::Arc;
/// # use std::sync::Arc;
/// # use ort::{session::{run_options::RunOptions, Session, WorkloadType}, tensor::TensorElementType, value::{Value, ValueType, TensorRef}};
/// # fn main() -> ort::Result<()> {
/// let session = Session::builder()?.commit_from_file("tests/data/upsample.onnx")?;
Expand Down
12 changes: 6 additions & 6 deletions src/session/run_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{
/// Allows selecting/deselecting/preallocating the outputs of a [`Session`] inference call.
///
/// ```
/// # use alloc::sync::Arc;
/// # use std::sync::Arc;
/// # use ort::{session::{Session, run_options::{RunOptions, OutputSelector}}, memory::Allocator, value::Tensor};
/// # fn main() -> ort::Result<()> {
/// let session = Session::builder()?.commit_from_file("tests/data/upsample.onnx")?;
Expand Down Expand Up @@ -98,7 +98,7 @@ impl OutputSelector {
/// for an ODE or embeddings model.
///
/// ```
/// # use alloc::sync::Arc;
/// # use std::sync::Arc;
/// # use ort::{session::{Session, run_options::{RunOptions, OutputSelector}}, memory::Allocator, value::Tensor};
/// # fn main() -> ort::Result<()> {
/// let session = Session::builder()?.commit_from_file("tests/data/upsample.onnx")?;
Expand Down Expand Up @@ -196,7 +196,7 @@ impl<O: SelectedOutputMarker> RunOptions<O> {
/// See [`OutputSelector`] for more details.
///
/// ```
/// # use alloc::sync::Arc;
/// # use std::sync::Arc;
/// # use ort::{session::{Session, run_options::{RunOptions, OutputSelector}}, memory::Allocator, value::Tensor};
/// # fn main() -> ort::Result<()> {
/// let session = Session::builder()?.commit_from_file("tests/data/upsample.onnx")?;
Expand Down Expand Up @@ -251,7 +251,7 @@ impl<O: SelectedOutputMarker> RunOptions<O> {
///
/// ```no_run
/// # // no_run because upsample.onnx is too simple of a model for the termination signal to be reliable enough
/// # use alloc::sync::Arc;
/// # use std::sync::Arc;
/// # use ort::{session::{Session, run_options::{RunOptions, OutputSelector}}, value::Value};
/// # fn main() -> ort::Result<()> {
/// # let session = Session::builder()?.commit_from_file("tests/data/upsample.onnx")?;
Expand Down Expand Up @@ -280,7 +280,7 @@ impl<O: SelectedOutputMarker> RunOptions<O> {
/// Resets the termination flag for the runs associated with [`RunOptions`].
///
/// ```no_run
/// # use alloc::sync::Arc;
/// # use std::sync::Arc;
/// # use ort::{session::{Session, run_options::{RunOptions, OutputSelector}}, value::Value};
/// # fn main() -> ort::Result<()> {
/// # let session = Session::builder()?.commit_from_file("tests/data/upsample.onnx")?;
Expand Down Expand Up @@ -309,7 +309,7 @@ impl<O: SelectedOutputMarker> RunOptions<O> {
/// This can be used to, for example, configure the graph ID when using compute graphs with an execution provider
/// like CUDA:
/// ```no_run
/// # use alloc::sync::Arc;
/// # use std::sync::Arc;
/// # use ort::session::run_options::RunOptions;
/// # fn main() -> ort::Result<()> {
/// let mut run_options = RunOptions::new()?;
Expand Down
6 changes: 3 additions & 3 deletions src/value/impl_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl<K: PrimitiveTensorElementType + Debug + Clone + Hash + Eq + 'static, V: Pri
/// Creates a [`Map`] from an iterable emitting `K` and `V`.
///
/// ```
/// # use alloc::collections::HashMap;
/// # use std::collections::HashMap;
/// # use ort::value::Map;
/// # fn main() -> ort::Result<()> {
/// let mut map = HashMap::<i64, f32>::new();
Expand All @@ -223,7 +223,7 @@ impl<V: PrimitiveTensorElementType + Debug + Clone + 'static> Value<MapValueType
/// Creates a [`Map`] from an iterable emitting `K` and `V`.
///
/// ```
/// # use alloc::collections::HashMap;
/// # use std::collections::HashMap;
/// # use ort::value::Map;
/// # fn main() -> ort::Result<()> {
/// let mut map = HashMap::<String, f32>::new();
Expand All @@ -247,7 +247,7 @@ impl<K: IntoTensorElementType + Debug + Clone + Hash + Eq + 'static, V: IntoTens
/// Creates a [`Map`] from two tensors of keys & values respectively.
///
/// ```
/// # use alloc::collections::HashMap;
/// # use std::collections::HashMap;
/// # use ort::value::{Map, Tensor};
/// # fn main() -> ort::Result<()> {
/// let keys = Tensor::<i64>::from_array(([4], vec![0, 1, 2, 3]))?;
Expand Down
10 changes: 5 additions & 5 deletions src/value/impl_tensor/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl<Type: TensorValueTypeMarker + ?Sized> Value<Type> {
/// - the alternative function for strings, [`Tensor::try_extract_string_tensor`].
///
/// ```
/// # use alloc::sync::Arc;
/// # use std::sync::Arc;
/// # use ort::value::TensorRef;
/// # fn main() -> ort::Result<()> {
/// let array = ndarray::Array4::<f32>::ones((1, 16, 16, 3));
Expand Down Expand Up @@ -75,7 +75,7 @@ impl<Type: TensorValueTypeMarker + ?Sized> Value<Type> {
/// Attempt to extract the scalar from a tensor of type `T`.
///
/// ```
/// # use alloc::sync::Arc;
/// # use std::sync::Arc;
/// # use ort::value::Tensor;
/// # fn main() -> ort::Result<()> {
/// let value = Tensor::from_array(((), vec![3.14_f32]))?.into_dyn();
Expand Down Expand Up @@ -133,7 +133,7 @@ impl<Type: TensorValueTypeMarker + ?Sized> Value<Type> {
/// See also the infallible counterpart, [`Tensor::extract_tensor_mut`], for typed [`Tensor<T>`]s.
///
/// ```
/// # use alloc::sync::Arc;
/// # use std::sync::Arc;
/// # use ort::value::TensorRefMut;
/// # fn main() -> ort::Result<()> {
/// let mut array = ndarray::Array4::<f32>::ones((1, 16, 16, 3));
Expand Down Expand Up @@ -451,7 +451,7 @@ impl<T: PrimitiveTensorElementType + Debug> Tensor<T> {
/// Extracts the underlying data into a read-only [`ndarray::ArrayView`].
///
/// ```
/// # use alloc::sync::Arc;
/// # use std::sync::Arc;
/// # use ort::value::TensorRef;
/// # fn main() -> ort::Result<()> {
/// let array = ndarray::Array4::<f32>::ones((1, 16, 16, 3));
Expand All @@ -471,7 +471,7 @@ impl<T: PrimitiveTensorElementType + Debug> Tensor<T> {
/// Extracts the underlying data into a mutable [`ndarray::ArrayViewMut`].
///
/// ```
/// # use alloc::sync::Arc;
/// # use std::sync::Arc;
/// # use ort::value::TensorRefMut;
/// # fn main() -> ort::Result<()> {
/// let mut array = ndarray::Array4::<f32>::ones((1, 16, 16, 3));
Expand Down
2 changes: 1 addition & 1 deletion src/value/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{ortsys, tensor::TensorElementType};
/// The type of a [`Value`][super::Value], or a session input/output.
///
/// ```
/// # use alloc::sync::Arc;
/// # use std::sync::Arc;
/// # use ort::{session::Session, value::{ValueType, Tensor}, tensor::TensorElementType};
/// # fn main() -> ort::Result<()> {
/// # let session = Session::builder()?.commit_from_file("tests/data/upsample.onnx")?;
Expand Down

0 comments on commit 77f7a9f

Please sign in to comment.