Skip to content

Commit 134dacc

Browse files
committed
'0517'
1 parent 140ee83 commit 134dacc

File tree

19 files changed

+1030
-1030
lines changed

19 files changed

+1030
-1030
lines changed

src/algorithm/mod.rs

Lines changed: 78 additions & 78 deletions
Large diffs are not rendered by default.

src/blas/mod.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -130,20 +130,20 @@ pub fn gemm<T>(
130130
) where
131131
T: HasAfEnum + FloatingPoint,
132132
{
133-
unsafe {
134-
let mut out = output.get();
135-
let err_val = af_gemm(
133+
134+
let mut out = unsafe { output.get() };
135+
let err_val =unsafe { af_gemm(
136136
&mut out as *mut af_array,
137137
optlhs as c_uint,
138138
optrhs as c_uint,
139139
alpha.as_ptr() as *const c_void,
140140
lhs.get(),
141141
rhs.get(),
142142
beta.as_ptr() as *const c_void,
143-
);
143+
)};
144144
HANDLE_ERROR(AfError::from(err_val));
145145
output.set(out);
146-
}
146+
147147
}
148148

149149
/// Matrix multiple of two Arrays
@@ -162,18 +162,18 @@ pub fn matmul<T>(lhs: &Array<T>, rhs: &Array<T>, optlhs: MatProp, optrhs: MatPro
162162
where
163163
T: HasAfEnum + FloatingPoint,
164164
{
165-
unsafe {
165+
166166
let mut temp: af_array = std::ptr::null_mut();
167-
let err_val = af_matmul(
167+
let err_val = unsafe {af_matmul(
168168
&mut temp as *mut af_array,
169169
lhs.get(),
170170
rhs.get(),
171171
optlhs as c_uint,
172172
optrhs as c_uint,
173-
);
173+
) };
174174
HANDLE_ERROR(AfError::from(err_val));
175175
temp.into()
176-
}
176+
177177
}
178178

179179
/// Calculate the dot product of vectors.
@@ -194,18 +194,18 @@ pub fn dot<T>(lhs: &Array<T>, rhs: &Array<T>, optlhs: MatProp, optrhs: MatProp)
194194
where
195195
T: HasAfEnum + FloatingPoint,
196196
{
197-
unsafe {
197+
198198
let mut temp: af_array = std::ptr::null_mut();
199-
let err_val = af_dot(
199+
let err_val = unsafe {af_dot(
200200
&mut temp as *mut af_array,
201201
lhs.get(),
202202
rhs.get(),
203203
optlhs as c_uint,
204204
optrhs as c_uint,
205-
);
205+
)};
206206
HANDLE_ERROR(AfError::from(err_val));
207207
temp.into()
208-
}
208+
209209
}
210210

211211
/// Transpose of a matrix.
@@ -220,12 +220,12 @@ where
220220
///
221221
/// Transposed Array.
222222
pub fn transpose<T: HasAfEnum>(arr: &Array<T>, conjugate: bool) -> Array<T> {
223-
unsafe {
223+
224224
let mut temp: af_array = std::ptr::null_mut();
225-
let err_val = af_transpose(&mut temp as *mut af_array, arr.get(), conjugate);
225+
let err_val = unsafe {af_transpose(&mut temp as *mut af_array, arr.get(), conjugate) };
226226
HANDLE_ERROR(AfError::from(err_val));
227227
temp.into()
228-
}
228+
229229
}
230230

231231
/// Inplace transpose of a matrix.
@@ -236,10 +236,10 @@ pub fn transpose<T: HasAfEnum>(arr: &Array<T>, conjugate: bool) -> Array<T> {
236236
/// - `conjugate` is a boolean that indicates if the transpose operation needs to be a conjugate
237237
/// transpose
238238
pub fn transpose_inplace<T: HasAfEnum>(arr: &mut Array<T>, conjugate: bool) {
239-
unsafe {
240-
let err_val = af_transpose_inplace(arr.get(), conjugate);
239+
240+
let err_val = unsafe {af_transpose_inplace(arr.get(), conjugate)};
241241
HANDLE_ERROR(AfError::from(err_val));
242-
}
242+
243243
}
244244

245245
/// Sets the cuBLAS math mode for the internal handle.

src/core/arith.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ where
108108
type Output = Array<T>;
109109

110110
fn not(self) -> Self::Output {
111-
unsafe {
111+
112112
let mut temp: af_array = std::ptr::null_mut();
113-
let err_val = af_not(&mut temp as *mut af_array, self.get());
113+
let err_val = unsafe { af_not(&mut temp as *mut af_array, self.get()) };
114114
HANDLE_ERROR(AfError::from(err_val));
115115
temp.into()
116-
}
116+
117117
}
118118
}
119119

@@ -124,12 +124,12 @@ macro_rules! unary_func {
124124
/// This is an element wise unary operation.
125125
pub fn $fn_name<T: HasAfEnum>(input: &Array<T>) -> Array< T::$out_type >
126126
where T::$out_type: HasAfEnum {
127-
unsafe {
127+
128128
let mut temp: af_array = std::ptr::null_mut();
129-
let err_val = $ffi_fn(&mut temp as *mut af_array, input.get());
129+
let err_val = unsafe { $ffi_fn(&mut temp as *mut af_array, input.get()) };
130130
HANDLE_ERROR(AfError::from(err_val));
131131
temp.into()
132-
}
132+
133133
}
134134
)
135135
}
@@ -256,12 +256,12 @@ macro_rules! unary_boolean_func {
256256
///
257257
/// This is an element wise unary operation.
258258
pub fn $fn_name<T: HasAfEnum>(input: &Array<T>) -> Array<bool> {
259-
unsafe {
259+
260260
let mut temp: af_array = std::ptr::null_mut();
261-
let err_val = $ffi_fn(&mut temp as *mut af_array, input.get());
261+
let err_val = unsafe { $ffi_fn(&mut temp as *mut af_array, input.get()) };
262262
HANDLE_ERROR(AfError::from(err_val));
263263
temp.into()
264-
}
264+
265265
}
266266
)
267267
}
@@ -291,12 +291,12 @@ macro_rules! binary_func {
291291
A: ImplicitPromote<B>,
292292
B: ImplicitPromote<A>,
293293
{
294-
unsafe {
294+
295295
let mut temp: af_array = std::ptr::null_mut();
296-
let err_val = $ffi_fn(&mut temp as *mut af_array, lhs.get(), rhs.get(), batch);
296+
let err_val = unsafe { $ffi_fn(&mut temp as *mut af_array, lhs.get(), rhs.get(), batch) };
297297
HANDLE_ERROR(AfError::from(err_val));
298298
Into::<Array<A::Output>>::into(temp)
299-
}
299+
300300
}
301301
};
302302
}
@@ -389,12 +389,12 @@ macro_rules! overloaded_binary_func {
389389
A: ImplicitPromote<B>,
390390
B: ImplicitPromote<A>,
391391
{
392-
unsafe {
392+
393393
let mut temp: af_array = std::ptr::null_mut();
394-
let err_val = $ffi_name(&mut temp as *mut af_array, lhs.get(), rhs.get(), batch);
394+
let err_val = unsafe { $ffi_name(&mut temp as *mut af_array, lhs.get(), rhs.get(), batch) };
395395
HANDLE_ERROR(AfError::from(err_val));
396396
temp.into()
397-
}
397+
398398
}
399399

400400
#[doc=$doc_str]
@@ -491,12 +491,12 @@ macro_rules! overloaded_logic_func {
491491
A: ImplicitPromote<B>,
492492
B: ImplicitPromote<A>,
493493
{
494-
unsafe {
494+
495495
let mut temp: af_array = std::ptr::null_mut();
496-
let err_val = $ffi_name(&mut temp as *mut af_array, lhs.get(), rhs.get(), batch);
496+
let err_val = unsafe { $ffi_name(&mut temp as *mut af_array, lhs.get(), rhs.get(), batch) };
497497
HANDLE_ERROR(AfError::from(err_val));
498498
temp.into()
499-
}
499+
500500
}
501501

502502
#[doc=$doc_str]
@@ -611,18 +611,18 @@ where
611611
X: ImplicitPromote<Y>,
612612
Y: ImplicitPromote<X>,
613613
{
614-
unsafe {
614+
615615
let mut temp: af_array = std::ptr::null_mut();
616-
let err_val = af_clamp(
616+
let err_val = unsafe { af_clamp(
617617
&mut temp as *mut af_array,
618618
inp.get(),
619619
lo.get(),
620620
hi.get(),
621621
batch,
622-
);
622+
) };
623623
HANDLE_ERROR(AfError::from(err_val));
624624
temp.into()
625-
}
625+
626626
}
627627

628628
/// Clamp the values of Array
@@ -979,10 +979,10 @@ pub fn bitnot<T: HasAfEnum>(input: &Array<T>) -> Array<T>
979979
where
980980
T: HasAfEnum + IntegralType,
981981
{
982-
unsafe {
982+
983983
let mut temp: af_array = std::ptr::null_mut();
984-
let err_val = af_bitnot(&mut temp as *mut af_array, input.get());
984+
let err_val = unsafe { af_bitnot(&mut temp as *mut af_array, input.get()) };
985985
HANDLE_ERROR(AfError::from(err_val));
986986
temp.into()
987-
}
987+
988988
}

0 commit comments

Comments
 (0)