use hpt_common::{
layout::layout::Layout, shape::shape::Shape, strides::strides::Strides, utils::pointer::Pointer,
};
use hpt_types::{
dtype::TypeCommon,
into_scalar::Cast,
type_promote::{
FloatOutBinary, FloatOutBinaryPromote, FloatOutUnary, FloatOutUnaryPromote, NormalOut,
NormalOutPromote, NormalOutUnary,
},
};
use std::fmt::Debug;
use std::fmt::Display;
pub trait TensorInfo<T> {
#[track_caller]
fn ptr(&self) -> Pointer<T>;
#[track_caller]
fn size(&self) -> usize;
#[track_caller]
fn shape(&self) -> &Shape;
#[track_caller]
fn strides(&self) -> &Strides;
#[track_caller]
fn layout(&self) -> &Layout;
#[track_caller]
fn parent(&self) -> Option<Pointer<T>>;
#[track_caller]
fn ndim(&self) -> usize;
#[track_caller]
fn is_contiguous(&self) -> bool;
#[track_caller]
fn elsize() -> usize {
size_of::<T>()
}
}
pub trait TensorLike<T>: Sized {
fn as_raw(&self) -> &[T];
fn as_raw_mut(&mut self) -> &mut [T];
fn elsize() -> usize {
size_of::<T>()
}
}
pub trait CommonBounds
where
<Self as TypeCommon>::Vec: Send + Sync + Copy,
Self: Sync
+ Send
+ Clone
+ Copy
+ TypeCommon
+ 'static
+ Display
+ Debug
+ Cast<Self>
+ NormalOut<Self, Output = Self>
+ FloatOutUnary
+ NormalOut<<Self as FloatOutUnary>::Output, Output = <Self as FloatOutUnary>::Output>
+ FloatOutBinary<<Self as FloatOutUnary>::Output, Output = <Self as FloatOutUnary>::Output>
+ FloatOutBinary<Self>
+ NormalOut<
<Self as FloatOutBinary<Self>>::Output,
Output = <Self as FloatOutBinary<Self>>::Output,
>
+ NormalOutUnary
+ FloatOutUnaryPromote
+ FloatOutBinaryPromote
+ NormalOutPromote
+ Cast<f64>,
{
}
impl<T> CommonBounds for T
where
<Self as TypeCommon>::Vec: Send + Sync + Copy,
Self: Sync
+ Send
+ Clone
+ Copy
+ TypeCommon
+ 'static
+ Display
+ Debug
+ Cast<Self>
+ NormalOut<Self, Output = Self>
+ FloatOutUnary
+ NormalOut<<Self as FloatOutUnary>::Output, Output = <Self as FloatOutUnary>::Output>
+ FloatOutBinary<<Self as FloatOutUnary>::Output, Output = <Self as FloatOutUnary>::Output>
+ FloatOutBinary<Self>
+ FloatOutBinary<
<Self as FloatOutBinary<Self>>::Output,
Output = <Self as FloatOutBinary<Self>>::Output,
>
+ NormalOut<
<Self as FloatOutBinary<Self>>::Output,
Output = <Self as FloatOutBinary<Self>>::Output,
>
+ NormalOutUnary
+ FloatOutUnaryPromote
+ FloatOutBinaryPromote
+ NormalOutPromote
+ Cast<f64>,
{
}