1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
use std::borrow::Borrow;
use hpt_common::error::base::TensorError;
use crate::tensor::CommonBounds;
/// A trait for tensor comparison operations
pub trait TensorCmp<T: CommonBounds, C: CommonBounds> {
/// right hand side tensor type
type RHS;
/// output tensor type, normally a boolean tensor
type Output;
/// check if element from x is not equal to element from y
///
/// ## Parameters:
/// `rhs`: The right-hand side tensor.
///
/// ## Example:
/// ```rust
/// let a = Tensor::<f32>::new([2.0, 2.0, 2.0]);
/// let b = a.tensor_neq(&a)?; // [false false false]
/// ```
#[track_caller]
fn tensor_neq<D>(&self, rhs: D) -> Result<Self::Output, TensorError>
where
D: Borrow<Self::RHS>;
/// check if element from x is equal to element from y
///
/// ## Parameters:
/// `rhs`: The right-hand side tensor.
///
/// ## Example:
/// ```rust
/// let a = Tensor::<f32>::new([2.0, 2.0, 2.0]);
/// let b = a.tensor_eq(&a)?; // [true true true]
/// ```
#[track_caller]
fn tensor_eq<D>(&self, rhs: D) -> Result<Self::Output, TensorError>
where
D: Borrow<Self::RHS>;
/// check if element from x is less than the element from y
///
/// ## Parameters:
/// `rhs`: The right-hand side tensor.
///
/// ## Example:
/// ```rust
/// let a = Tensor::<f32>::new([2.0, 2.0, 2.0]);
/// let b = a.tensor_lt(&a)?; // [false false false]
/// ```
#[track_caller]
fn tensor_lt<D>(&self, rhs: D) -> Result<Self::Output, TensorError>
where
D: Borrow<Self::RHS>;
/// check if element from x is greater than the element from y
///
/// ## Parameters:
/// `rhs`: The right-hand side tensor.
///
/// ## Example:
/// ```rust
/// let a = Tensor::<f32>::new([2.0, 2.0, 2.0]);
/// let b = a.tensor_gt(&a)?; // [false false false]
/// ```
#[track_caller]
fn tensor_gt<D>(&self, rhs: D) -> Result<Self::Output, TensorError>
where
D: Borrow<Self::RHS>;
/// check if element from x is less or equal to the element from y
///
/// ## Parameters:
/// `rhs`: The right-hand side tensor.
///
/// ## Example:
/// ```rust
/// let a = Tensor::<f32>::new([2.0, 2.0, 2.0]);
/// let b = a.tensor_le(&a)?; // [true true true]
/// ```
#[track_caller]
fn tensor_le<D>(&self, rhs: D) -> Result<Self::Output, TensorError>
where
D: Borrow<Self::RHS>;
/// check if element from x is greater or equal to the element from y
///
/// ## Parameters:
/// `rhs`: The right-hand side tensor.
///
/// ## Example:
/// ```rust
/// let a = Tensor::<f32>::new([2.0, 2.0, 2.0]);
/// let b = a.tensor_ge(&a)?; // [true true true]
/// ```
#[track_caller]
fn tensor_ge<D>(&self, rhs: D) -> Result<Self::Output, TensorError>
where
D: Borrow<Self::RHS>;
}