Skip to content

Commit

Permalink
trait RunContextを削除
Browse files Browse the repository at this point in the history
  • Loading branch information
qryxip committed Nov 11, 2023
1 parent 1b1b7bf commit c39f48c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
17 changes: 1 addition & 16 deletions crates/voicevox_core/src/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pub(crate) mod status;
use std::fmt::Debug;

use derive_new::new;
use easy_ext::ext;
use enum_map::Enum;
use ndarray::{Array, ArrayD, Dimension, ShapeError};
use thiserror::Error;
Expand All @@ -15,7 +14,7 @@ use crate::SupportedDevices;

pub(crate) trait InferenceRuntime: 'static {
type Session: Sized + Send + 'static;
type RunContext<'a>: RunContext<'a, Runtime = Self>;
type RunContext<'a>: From<&'a mut Self::Session>;

fn supported_devices() -> crate::Result<SupportedDevices>;

Expand All @@ -32,20 +31,6 @@ pub(crate) trait InferenceRuntime: 'static {
fn run(ctx: Self::RunContext<'_>) -> anyhow::Result<Vec<OutputTensor>>;
}

pub(crate) trait RunContext<'a>:
From<&'a mut <Self::Runtime as InferenceRuntime>::Session>
{
type Runtime: InferenceRuntime<RunContext<'a> = Self>;
}

#[ext(RunContextExt)]
impl<'a, T: RunContext<'a>> T {
fn with_input(mut self, tensor: Array<impl InputScalar, impl Dimension + 'static>) -> Self {
T::Runtime::push_input(tensor, &mut self);
self
}
}

pub(crate) trait InferenceGroup {
type Kind: Copy + Enum;
}
Expand Down
5 changes: 0 additions & 5 deletions crates/voicevox_core/src/infer/runtimes/onnxruntime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::{
error::ErrorRepr,
infer::{
DecryptModelError, InferenceRuntime, InferenceSessionOptions, InputScalar, OutputTensor,
RunContext,
},
};

Expand Down Expand Up @@ -141,10 +140,6 @@ impl<'sess> From<&'sess mut AssertSend<onnxruntime::session::Session<'static>>>
}
}

impl<'sess> RunContext<'sess> for OnnxruntimeRunContext<'sess> {
type Runtime = Onnxruntime;
}

// FIXME: 以下のことをちゃんと確認した後、onnxruntime-rs側で`Session`が`Send`であると宣言する。
// https://github.com/VOICEVOX/voicevox_core/issues/307#issuecomment-1276184614
mod assert_send {
Expand Down

0 comments on commit c39f48c

Please sign in to comment.