scirs2_series/gpu_acceleration/
traits.rs1use scirs2_core::ndarray::Array1;
7use scirs2_core::numeric::Float;
8use std::fmt::Debug;
9
10use super::config::GpuConfig;
11use crate::error::Result;
12
13pub trait GpuAccelerated<F: Float + Debug> {
15 fn to_gpu(&self, config: &GpuConfig) -> Result<Self>
17 where
18 Self: Sized;
19
20 fn to_cpu(&self) -> Result<Self>
22 where
23 Self: Sized;
24
25 fn is_on_gpu(&self) -> bool;
27
28 fn gpu_memory_usage(&self) -> usize;
30}
31
32pub type DecompositionResult<F> = (Array1<F>, Array1<F>, Array1<F>);
34
35pub trait GpuForecasting<F: Float + Debug> {
37 fn forecast_gpu(&self, steps: usize, config: &GpuConfig) -> Result<Array1<F>>;
39
40 fn batch_forecast_gpu(
42 &self,
43 data: &[Array1<F>],
44 steps: usize,
45 config: &GpuConfig,
46 ) -> Result<Vec<Array1<F>>>;
47}
48
49pub trait GpuDecomposition<F: Float + Debug> {
51 fn decompose_gpu(&self, config: &GpuConfig) -> Result<DecompositionResult<F>>;
53
54 fn batch_decompose_gpu(
56 &self,
57 data: &[Array1<F>],
58 config: &GpuConfig,
59 ) -> Result<Vec<DecompositionResult<F>>>;
60}
61
62pub trait GpuFeatureExtraction<F: Float + Debug> {
64 fn extract_features_gpu(&self, config: &GpuConfig) -> Result<Array1<F>>;
66
67 fn batch_extract_features_gpu(
69 &self,
70 data: &[Array1<F>],
71 config: &GpuConfig,
72 ) -> Result<Vec<Array1<F>>>;
73}