Skip to content

Commit b307191

Browse files
committed
Reorganize all mandatory modules into a parent module, core
1 parent e51cad4 commit b307191

File tree

29 files changed

+210
-219
lines changed

29 files changed

+210
-219
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ indexing = []
2727
graphics = []
2828
image = []
2929
lapack = []
30-
machine_learning = []
30+
ml = []
3131
macros = []
3232
random = []
3333
signal = []
3434
sparse = []
3535
statistics = []
3636
vision = []
3737
default = ["algorithm", "arithmetic", "blas", "data", "indexing", "graphics", "image", "lapack",
38-
"machine_learning", "macros", "random", "signal", "sparse", "statistics", "vision"]
38+
"ml", "macros", "random", "signal", "sparse", "statistics", "vision"]
3939

4040
[dependencies]
4141
libc = "0.2"

examples/using_half.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ fn main() {
55
set_device(0);
66
info();
77

8-
let values: Vec<_> = (1u8..101).map(f32::from).collect();
8+
let values: Vec<_> = (1u8..101).map(std::convert::From::from).collect();
99

1010
let half_values = values.iter().map(|&x| f16::from_f32(x)).collect::<Vec<_>>();
1111

src/algorithm/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use crate::array::Array;
2-
use crate::defines::{AfError, BinaryOp};
3-
use crate::error::HANDLE_ERROR;
4-
use crate::util::af_array;
5-
use crate::util::{HasAfEnum, RealNumber, ReduceByKeyInput, Scanable};
1+
use super::core::{
2+
af_array, AfError, Array, BinaryOp, HasAfEnum, RealNumber, ReduceByKeyInput, Scanable,
3+
HANDLE_ERROR,
4+
};
5+
66
use libc::{c_double, c_int, c_uint};
77

88
extern "C" {

src/blas/mod.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
use crate::array::Array;
2-
use crate::defines::{AfError, MatProp};
3-
use crate::error::HANDLE_ERROR;
4-
use crate::util::{af_array, to_u32};
5-
use crate::util::{FloatingPoint, HasAfEnum};
1+
use super::core::{af_array, AfError, Array, FloatingPoint, HasAfEnum, MatProp, HANDLE_ERROR};
2+
63
use libc::{c_int, c_uint, c_void};
74
use std::vec::Vec;
85

@@ -133,8 +130,8 @@ pub fn gemm<T>(
133130
let mut out = output.get();
134131
let err_val = af_gemm(
135132
&mut out as *mut af_array,
136-
to_u32(optlhs) as c_uint,
137-
to_u32(optrhs) as c_uint,
133+
optlhs as c_uint,
134+
optrhs as c_uint,
138135
alpha.as_ptr() as *const c_void,
139136
lhs.get(),
140137
rhs.get(),
@@ -167,8 +164,8 @@ where
167164
&mut temp as *mut af_array,
168165
lhs.get(),
169166
rhs.get(),
170-
to_u32(optlhs) as c_uint,
171-
to_u32(optrhs) as c_uint,
167+
optlhs as c_uint,
168+
optrhs as c_uint,
172169
);
173170
HANDLE_ERROR(AfError::from(err_val));
174171
temp.into()
@@ -199,8 +196,8 @@ where
199196
&mut temp as *mut af_array,
200197
lhs.get(),
201198
rhs.get(),
202-
to_u32(optlhs) as c_uint,
203-
to_u32(optrhs) as c_uint,
199+
optlhs as c_uint,
200+
optrhs as c_uint,
204201
);
205202
HANDLE_ERROR(AfError::from(err_val));
206203
temp.into()

src/arith/mod.rs renamed to src/core/arith.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
use crate::array::Array;
2-
use crate::data::{constant, tile, ConstGenerator};
3-
use crate::defines::AfError;
4-
use crate::dim4::Dim4;
5-
use crate::error::HANDLE_ERROR;
6-
use crate::num::Zero;
7-
use crate::util::{af_array, HasAfEnum, ImplicitPromote};
1+
use super::array::Array;
2+
use super::data::{constant, tile, ConstGenerator};
3+
use super::defines::AfError;
4+
use super::dim4::Dim4;
5+
use super::error::HANDLE_ERROR;
6+
use super::util::{af_array, HasAfEnum, ImplicitPromote};
7+
use num::Zero;
8+
89
use libc::c_int;
910
use num::Complex;
1011
use std::ops::Neg;
@@ -818,9 +819,7 @@ arith_func!(BitXor, bitxor, bitxor);
818819
mod op_assign {
819820

820821
use super::*;
821-
use crate::array::Array;
822-
use crate::index::{assign_gen, Indexer};
823-
use crate::seq::Seq;
822+
use crate::core::{assign_gen, Array, Indexer, Seq};
824823
use std::ops::{AddAssign, DivAssign, MulAssign, RemAssign, SubAssign};
825824
use std::ops::{BitAndAssign, BitOrAssign, BitXorAssign, ShlAssign, ShrAssign};
826825

src/array.rs renamed to src/core/array.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
use crate::defines::{AfError, Backend, DType};
2-
use crate::dim4::Dim4;
3-
use crate::error::HANDLE_ERROR;
4-
use crate::util::{af_array, dim_t, void_ptr, HasAfEnum};
1+
use super::defines::{AfError, Backend, DType};
2+
use super::dim4::Dim4;
3+
use super::error::HANDLE_ERROR;
4+
use super::util::{af_array, dim_t, void_ptr, HasAfEnum};
5+
56
use libc::{c_char, c_int, c_longlong, c_uint, c_void};
67
use std::ffi::CString;
78
use std::marker::PhantomData;

src/backend.rs renamed to src/core/backend.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
extern crate libc;
1+
use super::defines::{AfError, Backend};
2+
use super::error::HANDLE_ERROR;
23

3-
use self::libc::{c_int, c_uint};
4-
use crate::defines::{AfError, Backend};
5-
use crate::error::HANDLE_ERROR;
4+
use libc::{c_int, c_uint};
65

76
extern "C" {
87
fn af_set_backend(bknd: u8) -> c_int;

src/data/mod.rs renamed to src/core/data.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
use crate::array::Array;
2-
use crate::defines::{AfError, BorderType};
3-
use crate::dim4::Dim4;
4-
use crate::error::HANDLE_ERROR;
5-
use crate::util::{af_array, c32, c64, dim_t, u64_t, HasAfEnum};
1+
use super::array::Array;
2+
use super::defines::{AfError, BorderType};
3+
use super::dim4::Dim4;
4+
use super::error::HANDLE_ERROR;
5+
use super::util::{af_array, c32, c64, dim_t, u64_t, HasAfEnum};
6+
67
use libc::{c_double, c_int, c_uint};
78
use std::option::Option;
89
use std::vec::Vec;

src/defines.rs renamed to src/core/defines.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,27 +247,29 @@ pub enum ColorSpace {
247247
#[derive(Clone, Copy, Debug, PartialEq)]
248248
pub enum MatProp {
249249
/// Default (no-op)
250-
NONE,
250+
NONE = 0,
251251
/// Data needs to be transposed
252-
TRANS,
252+
TRANS = 1,
253253
/// Data needs to be conjugate transposed
254-
CTRANS,
254+
CTRANS = 2,
255255
/// Matrix is upper triangular
256-
UPPER,
256+
CONJ = 4,
257+
/// Matrix needs to be conjugate
258+
UPPER = 32,
257259
/// Matrix is lower triangular
258-
LOWER,
260+
LOWER = 64,
259261
/// Matrix diagonal has unitary values
260-
DIAGUNIT,
262+
DIAGUNIT = 128,
261263
/// Matrix is symmetric
262-
SYM,
264+
SYM = 512,
263265
/// Matrix is positive definite
264-
POSDEF,
266+
POSDEF = 1024,
265267
/// Matrix is orthogonal
266-
ORTHOG,
268+
ORTHOG = 2048,
267269
/// Matrix is tri-diagonal
268-
TRIDIAG,
270+
TRIDIAG = 4096,
269271
/// Matrix is block-diagonal
270-
BLOCKDIAG,
272+
BLOCKDIAG = 8192,
271273
}
272274

273275
/// Norm type

src/device/mod.rs renamed to src/core/device.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
extern crate libc;
1+
use super::defines::AfError;
2+
use super::error::HANDLE_ERROR;
3+
use super::util::free_host;
24

3-
use self::libc::{c_char, c_int, size_t};
4-
use crate::defines::AfError;
5-
use crate::error::HANDLE_ERROR;
6-
use crate::util::free_host;
5+
use libc::{c_char, c_int, size_t};
76
use std::borrow::Cow;
87
use std::ffi::{CStr, CString};
98

0 commit comments

Comments
 (0)