tenferro_linalg_prims/backend/
hip.rs1use tenferro_device::{Error, Result};
2use tenferro_tensor::Tensor;
3
4use super::TensorLinalgContextFor;
5use crate::{
6 CholeskyTensorExResult, EigTensorResult, EigenTensorResult, KernelLinalgScalar,
7 LinalgCapabilityOp, LuTensorExResult, LuTensorResult, QrTensorResult, SolveTensorExResult,
8 SvdTensorResult, TensorLinalgPrims,
9};
10
11#[derive(Debug, Default, Clone, Copy)]
19pub struct HipTensorLinalgBackend;
20
21fn unsupported<T>() -> Result<T> {
22 Err(Error::DeviceError(
23 "HIP linalg backend is not yet implemented".into(),
24 ))
25}
26
27impl<T: KernelLinalgScalar> TensorLinalgPrims<T> for HipTensorLinalgBackend {
28 type Context = tenferro_prims::RocmContext;
29
30 fn has_linalg_support(_op: LinalgCapabilityOp) -> bool {
31 false
32 }
33
34 fn solve_ex(
35 _ctx: &mut Self::Context,
36 _a: &Tensor<T>,
37 _b: &Tensor<T>,
38 ) -> Result<SolveTensorExResult<T>> {
39 unsupported()
40 }
41
42 fn solve(_ctx: &mut Self::Context, _a: &Tensor<T>, _b: &Tensor<T>) -> Result<Tensor<T>> {
43 unsupported()
44 }
45
46 fn lu_solve(
47 _ctx: &mut Self::Context,
48 _factors: &Tensor<T>,
49 _pivots: &Tensor<i32>,
50 _b: &Tensor<T>,
51 ) -> Result<Tensor<T>> {
52 unsupported()
53 }
54
55 fn solve_triangular(
56 _ctx: &mut Self::Context,
57 _a: &Tensor<T>,
58 _b: &Tensor<T>,
59 _upper: bool,
60 ) -> Result<Tensor<T>> {
61 unsupported()
62 }
63
64 fn qr(_ctx: &mut Self::Context, _a: &Tensor<T>) -> Result<QrTensorResult<T>> {
65 unsupported()
66 }
67
68 fn thin_svd(_ctx: &mut Self::Context, _a: &Tensor<T>) -> Result<SvdTensorResult<T>> {
69 unsupported()
70 }
71
72 fn svdvals(_ctx: &mut Self::Context, _a: &Tensor<T>) -> Result<Tensor<T::Real>> {
73 unsupported()
74 }
75
76 fn lu_factor_ex(_ctx: &mut Self::Context, _a: &Tensor<T>) -> Result<LuTensorExResult<T>> {
77 unsupported()
78 }
79
80 fn lu_factor(_ctx: &mut Self::Context, _a: &Tensor<T>) -> Result<LuTensorResult<T>> {
81 unsupported()
82 }
83
84 fn lu_factor_no_pivot(_ctx: &mut Self::Context, _a: &Tensor<T>) -> Result<LuTensorResult<T>> {
85 unsupported()
86 }
87
88 fn cholesky_ex(_ctx: &mut Self::Context, _a: &Tensor<T>) -> Result<CholeskyTensorExResult<T>> {
89 unsupported()
90 }
91
92 fn cholesky(_ctx: &mut Self::Context, _a: &Tensor<T>) -> Result<Tensor<T>> {
93 unsupported()
94 }
95
96 fn eigen_sym(_ctx: &mut Self::Context, _a: &Tensor<T>) -> Result<EigenTensorResult<T>> {
97 unsupported()
98 }
99
100 fn eig(_ctx: &mut Self::Context, _a: &Tensor<T>) -> Result<EigTensorResult<T>> {
101 unsupported()
102 }
103}
104
105impl<T: KernelLinalgScalar> TensorLinalgContextFor<T> for tenferro_prims::RocmContext {
106 type Backend = HipTensorLinalgBackend;
107}