Skip to content

Commit 3867353

Browse files
committed
minor
1 parent fed4da6 commit 3867353

File tree

8 files changed

+138
-157
lines changed

8 files changed

+138
-157
lines changed

include/func0.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#include <cstddef>
77
#include <cstdint>
88
#include <iostream>
9-
#include <sys/cdefs.h>
10-
#include <sys/types.h>
119

1210
#include <array>
1311
#include <unordered_set>

include/op0.hpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "tensor.hpp"
33
namespace Ouroboros{
44
template<typename T>
5-
Tensor<T> operator~(const Tensor<T>& a){
5+
__always_inline Tensor<T> operator~(const Tensor<T>& a){
66
Tensor<T> result(a.shape());
77
for(std::size_t i=0;i<a.size();i++){
88
result[i]=~a[i];
@@ -11,15 +11,15 @@ Tensor<T> operator~(const Tensor<T>& a){
1111
}
1212

1313
template<typename T>
14-
Tensor<T> operator|(const Tensor<T>& a,const Tensor<T>& b){
14+
__always_inline Tensor<T> operator|(const Tensor<T>& a,const Tensor<T>& b){
1515
Tensor<T> result(a.shape());
1616
for(std::size_t i=0;i<a.size();i++){
1717
result[i]=a[i]|b[i];
1818
}
1919
return result;
2020
}
2121
template<typename T>
22-
Tensor<T> operator&(const Tensor<T>& a,const Tensor<T>& b){
22+
__always_inline Tensor<T> operator&(const Tensor<T>& a,const Tensor<T>& b){
2323
Tensor<T> result(a.shape());
2424
for(std::size_t i=0;i<a.size();i++){
2525
result[i]=a[i]&b[i];
@@ -28,23 +28,23 @@ Tensor<T> operator&(const Tensor<T>& a,const Tensor<T>& b){
2828
}
2929

3030
template<typename T>
31-
Tensor<T> operator^(const Tensor<T>& a,const Tensor<T>& b){
31+
__always_inline Tensor<T> operator^(const Tensor<T>& a,const Tensor<T>& b){
3232
Tensor<T> result(a.shape());
3333
for(std::size_t i=0;i<a.size();i++){
3434
result[i]=a[i]^b[i];
3535
}
3636
return result;
3737
}
3838
template<typename T>
39-
Tensor<T> operator<<(const Tensor<T>& a,const Tensor<T>& b){
39+
__always_inline Tensor<T> operator<<(const Tensor<T>& a,const Tensor<T>& b){
4040
Tensor<T> result(a.shape());
4141
for(std::size_t i=0;i<a.size();i++){
4242
result[i]=a[i]<<b[i];
4343
}
4444
return result;
4545
}
4646
template<typename T>
47-
Tensor<T> operator>>(const Tensor<T>& a,const Tensor<T>& b){
47+
__always_inline Tensor<T> operator>>(const Tensor<T>& a,const Tensor<T>& b){
4848
Tensor<T> result(a.shape());
4949
for(std::size_t i=0;i<a.size();i++){
5050
result[i]=a[i]>>b[i];
@@ -54,39 +54,39 @@ Tensor<T> operator>>(const Tensor<T>& a,const Tensor<T>& b){
5454

5555

5656
template<typename T>
57-
Tensor<T> operator|(const Tensor<T>& a,T b){
57+
__always_inline Tensor<T> operator|(const Tensor<T>& a,T b){
5858
Tensor<T> result(a.shape());
5959
for(std::size_t i=0;i<a.size();i++){
6060
result[i]=a[i]|b;
6161
}
6262
return result;
6363
}
6464
template<typename T>
65-
Tensor<T> operator&(const Tensor<T>& a,T b){
65+
__always_inline Tensor<T> operator&(const Tensor<T>& a,T b){
6666
Tensor<T> result(a.shape());
6767
for(std::size_t i=0;i<a.size();i++){
6868
result[i]=a[i]&b;
6969
}
7070
return result;
7171
}
7272
template<typename T>
73-
Tensor<T> operator^(const Tensor<T>& a,T b){
73+
__always_inline Tensor<T> operator^(const Tensor<T>& a,T b){
7474
Tensor<T> result(a.shape());
7575
for(std::size_t i=0;i<a.size();i++){
7676
result[i]=a[i]^b;
7777
}
7878
return result;
7979
}
8080
template<typename T>
81-
Tensor<T> operator<<(const Tensor<T>& a,T b){
81+
__always_inline Tensor<T> operator<<(const Tensor<T>& a,T b){
8282
Tensor<T> result(a.shape());
8383
for(std::size_t i=0;i<a.size();i++){
8484
result[i]=a[i]<<b;
8585
}
8686
return result;
8787
}
8888
template<typename T>
89-
Tensor<T> operator>>(const Tensor<T>& a,T b){
89+
__always_inline Tensor<T> operator>>(const Tensor<T>& a,T b){
9090
Tensor<T> result(a.shape());
9191
for(std::size_t i=0;i<a.size();i++){
9292
result[i]=a[i]>>b;
@@ -96,27 +96,27 @@ Tensor<T> operator>>(const Tensor<T>& a,T b){
9696

9797

9898
template<typename T>
99-
Tensor<T> operator|(T a,const Tensor<T>& b){
99+
__always_inline Tensor<T> operator|(T a,const Tensor<T>& b){
100100
return b|a;
101101
}
102102
template<typename T>
103-
Tensor<T> operator&(T a,const Tensor<T>& b){
103+
__always_inline Tensor<T> operator&(T a,const Tensor<T>& b){
104104
return b&a;
105105
}
106106
template<typename T>
107-
Tensor<T> operator^(T a,const Tensor<T>& b){
107+
__always_inline Tensor<T> operator^(T a,const Tensor<T>& b){
108108
return b^a;
109109
}
110110
template<typename T>
111-
Tensor<T> operator<<(T a,const Tensor<T>& b){
111+
__always_inline Tensor<T> operator<<(T a,const Tensor<T>& b){
112112
Tensor<T> result(b.shape());
113113
for(std::size_t i=0;i<b.size();i++){
114114
result[i]=a<<b[i];
115115
}
116116
return result;
117117
}
118118
template<typename T>
119-
Tensor<T> operator>>(T a,const Tensor<T>& b){
119+
__always_inline Tensor<T> operator>>(T a,const Tensor<T>& b){
120120
Tensor<T> result(b.shape());
121121
for(std::size_t i=0;i<b.size();i++){
122122
result[i]=a>>b[i];

include/op1.hpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Ouroboros{
66
template<typename T>
7-
Tensor<T> operator-(const Tensor<T>& a){
7+
__always_inline Tensor<T> operator-(const Tensor<T>& a){
88
Tensor<T> result(a.shape());
99
for(std::size_t i=0;i<a.size();i++){
1010
result[i]=-a[i];
@@ -13,31 +13,31 @@ Tensor<T> operator-(const Tensor<T>& a){
1313
}
1414

1515
template<typename T>
16-
Tensor<T> operator+(const Tensor<T>& a,const Tensor<T>& b){
16+
__always_inline Tensor<T> operator+(const Tensor<T>& a,const Tensor<T>& b){
1717
Tensor<T> result(a.shape());
1818
for(std::size_t i=0;i<a.size();i++){
1919
result[i]=a[i]+b[i];
2020
}
2121
return result;
2222
}
2323
template<typename T>
24-
Tensor<T> operator-(const Tensor<T>& a,const Tensor<T>& b){
24+
__always_inline Tensor<T> operator-(const Tensor<T>& a,const Tensor<T>& b){
2525
Tensor<T> result(a.shape());
2626
for(std::size_t i=0;i<a.size();i++){
2727
result[i]=a[i]-b[i];
2828
}
2929
return result;
3030
}
3131
template<typename T>
32-
Tensor<T> operator*(const Tensor<T>& a,const Tensor<T>& b){
32+
__always_inline Tensor<T> operator*(const Tensor<T>& a,const Tensor<T>& b){
3333
Tensor<T> result(a.shape());
3434
for(std::size_t i=0;i<a.size();i++){
3535
result[i]=a[i]*b[i];
3636
}
3737
return result;
3838
}
3939
template<typename T>
40-
Tensor<T> operator/(const Tensor<T>& a,const Tensor<T>& b){
40+
__always_inline Tensor<T> operator/(const Tensor<T>& a,const Tensor<T>& b){
4141
Tensor<T> result(a.shape());
4242
for(std::size_t i=0;i<a.size();i++){
4343
result[i]=a[i]/b[i];
@@ -46,48 +46,48 @@ Tensor<T> operator/(const Tensor<T>& a,const Tensor<T>& b){
4646
}
4747

4848
template<typename T>
49-
Tensor<T> operator+(const Tensor<T>& a,T b){
49+
__always_inline Tensor<T> operator+(const Tensor<T>& a,T b){
5050
Tensor<T> result(a.shape());
5151
for(std::size_t i=0;i<a.size();i++){
5252
result[i]=a[i]+b;
5353
}
5454
return result;
5555
}
5656
template<typename T>
57-
Tensor<T> operator-(const Tensor<T>& a,T b){
57+
__always_inline Tensor<T> operator-(const Tensor<T>& a,T b){
5858
return a+(-b);
5959
}
6060
template<typename T>
61-
Tensor<T> operator*(const Tensor<T>& a,T b){
61+
__always_inline Tensor<T> operator*(const Tensor<T>& a,T b){
6262
Tensor<T> result(a.shape());
6363
for(std::size_t i=0;i<a.size();i++){
6464
result[i]=a[i]*b;
6565
}
6666
return result;
6767
}
6868
template<typename T>
69-
Tensor<T> operator/(const Tensor<T>& a,T b){
69+
__always_inline Tensor<T> operator/(const Tensor<T>& a,T b){
7070
return a*((T)1/b);
7171
}
7272

7373
template<typename T>
74-
Tensor<T> operator+(T a,const Tensor<T>& b){
74+
__always_inline Tensor<T> operator+(T a,const Tensor<T>& b){
7575
return b+a;
7676
}
7777
template<typename T>
78-
Tensor<T> operator-(T a,const Tensor<T>& b){
78+
__always_inline Tensor<T> operator-(T a,const Tensor<T>& b){
7979
Tensor<T> result(b.shape());
8080
for(std::size_t i=0;i<b.size();i++){
8181
result[i]=a-b[i];
8282
}
8383
return result;
8484
}
8585
template<typename T>
86-
Tensor<T> operator*(T a,const Tensor<T>& b){
86+
__always_inline Tensor<T> operator*(T a,const Tensor<T>& b){
8787
return b*a;
8888
}
8989
template<typename T>
90-
Tensor<T> operator/(T a,const Tensor<T>& b){
90+
__always_inline Tensor<T> operator/(T a,const Tensor<T>& b){
9191
Tensor<T> result(b.shape());
9292
for(std::size_t i=0;i<b.size();i++){
9393
result[i]=a/b[i];
@@ -96,53 +96,53 @@ Tensor<T> operator/(T a,const Tensor<T>& b){
9696
}
9797

9898
template<typename T>
99-
void operator+=(Tensor<T>& a,const Tensor<T>& b){
99+
__always_inline void operator+=(Tensor<T>& a,const Tensor<T>& b){
100100
for(std::size_t i=0;i<a.size();i++){
101101
a[i]+=b[i];
102102
}
103103
}
104104
template<typename T>
105-
void operator-=(Tensor<T>& a,const Tensor<T>& b){
105+
__always_inline void operator-=(Tensor<T>& a,const Tensor<T>& b){
106106
for(std::size_t i=0;i<a.size();i++){
107107
a[i]-=b[i];
108108
}
109109
}
110110
template<typename T>
111-
void operator*=(Tensor<T>& a,const Tensor<T>& b){
111+
__always_inline void operator*=(Tensor<T>& a,const Tensor<T>& b){
112112
for(std::size_t i=0;i<a.size();i++){
113113
a[i]*=b[i];
114114
}
115115
}
116116
template<typename T>
117-
void operator/=(Tensor<T>& a,const Tensor<T>& b){
117+
__always_inline void operator/=(Tensor<T>& a,const Tensor<T>& b){
118118
for(std::size_t i=0;i<a.size();i++){
119119
a[i]/=b[i];
120120
}
121121
}
122122

123123
template<typename T>
124-
void operator+=(Tensor<T>& a,T b){
124+
__always_inline void operator+=(Tensor<T>& a,T b){
125125
for(std::size_t i=0;i<a.size();i++){
126126
a[i]+=b;
127127
}
128128
}
129129
template<typename T>
130-
void operator-=(Tensor<T>& a,T b){
130+
__always_inline void operator-=(Tensor<T>& a,T b){
131131
a+=(-b);
132132
}
133133
template<typename T>
134-
void operator*=(Tensor<T>& a,T b){
134+
__always_inline void operator*=(Tensor<T>& a,T b){
135135
for(std::size_t i=0;i<a.size();i++){
136136
a[i]*=b;
137137
}
138138
}
139139
template<typename T>
140-
void operator/=(Tensor<T>& a,T b){
140+
__always_inline void operator/=(Tensor<T>& a,T b){
141141
a*=((T)1/b);
142142
}
143143

144144
template<typename T>
145-
Tensor<T> matmul(const Tensor<T>& a,const Tensor<T>& b){
145+
__always_inline Tensor<T> matmul(const Tensor<T>& a,const Tensor<T>& b){
146146
Shape result_shape={a.shape()[0],b.shape()[1]};
147147
Tensor<T> result(result_shape);
148148
//Choose the right cblas function based on type T
@@ -167,7 +167,7 @@ Tensor<T> matmul(const Tensor<T>& a,const Tensor<T>& b){
167167
return result;
168168
}
169169
template<typename T>
170-
Tensor<T> matvecmul(const Tensor<T>& a,const Tensor<T>& b){
170+
__always_inline Tensor<T> matvecmul(const Tensor<T>& a,const Tensor<T>& b){
171171
Shape result_shape={a.shape()[0]};
172172
Tensor<T> result(result_shape);
173173
//Choose the right cblas function based on type T

0 commit comments

Comments
 (0)