1use crate::{Tensor, WithDType};
2
3pub enum TensorOrScalar<T: WithDType> {
4 Tensor(Tensor<T>),
5 Scalar(T),
6}
7
8impl<T: WithDType> From<T> for TensorOrScalar<T> {
9 fn from(value: T) -> Self {
10 TensorOrScalar::Scalar(value)
11 }
12}
13
14impl<T: WithDType> From<Tensor<T>> for TensorOrScalar<T> {
15 fn from(value: Tensor<T>) -> Self {
16 TensorOrScalar::Tensor(value)
17 }
18}
19
20impl<T: WithDType> From<&Tensor<T>> for TensorOrScalar<T> {
21 fn from(value: &Tensor<T>) -> Self {
22 TensorOrScalar::Tensor(value.clone())
23 }
24}
25