Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/helloworld.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ fn main() {

println!("Element-wise arithmetic");
let b = sin(&a)
.and_then(|x| add(&x, &1.5))
.and_then(|x| add(&x, &1.5, false))
.unwrap();

let b2 = sin(&a).
and_then(|x| {
cos(&a)
.and_then(|y| add(&x, &y))
.and_then(|y| add(&x, &y, false))
})
.unwrap();

Expand Down
2 changes: 1 addition & 1 deletion examples/histogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn main() {

let disp_img = man.dims()
.and_then(|x| constant(255 as f32, x))
.and_then(|x| div(&man, &x))
.and_then(|x| div(&man, &x, false))
.unwrap();

loop {
Expand Down
4 changes: 2 additions & 2 deletions examples/pi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ fn main() {
let start = PreciseTime::now();

for bench_iter in 0..100 {
let pi_val = add(&mul(x, x).unwrap(), &mul(y, y).unwrap())
let pi_val = add(&mul(x, x, false).unwrap(), &mul(y, y, false).unwrap(), false)
.and_then( |z| sqrt(&z) )
.and_then( |z| le(&z, &constant(1, dims).unwrap()) )
.and_then( |z| le(&z, &constant(1, dims).unwrap(), false) )
.and_then( |z| sum_all(&z) )
.map( |z| z.0 * 4.0/(samples as f64) )
.unwrap();
Expand Down
12 changes: 6 additions & 6 deletions src/arith/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,32 +223,32 @@ impl Convertable for Array {

macro_rules! overloaded_binary_func {
($fn_name: ident, $help_name: ident, $ffi_name: ident) => (
fn $help_name(lhs: &Array, rhs: &Array) -> Result<Array, AfError> {
fn $help_name(lhs: &Array, rhs: &Array, batch: bool) -> Result<Array, AfError> {
unsafe {
let mut temp: i64 = 0;
let err_val = $ffi_name(&mut temp as MutAfArray,
lhs.get() as AfArray, rhs.get() as AfArray,
0);
batch as c_int);
match err_val {
0 => Ok(Array::from(temp)),
_ => Err(AfError::from(err_val)),
}
}
}

pub fn $fn_name<T: Convertable, U: Convertable> (arg1: &T, arg2: &U) -> Result<Array, AfError> {
pub fn $fn_name<T: Convertable, U: Convertable> (arg1: &T, arg2: &U, batch: bool) -> Result<Array, AfError> {
let lhs = arg1.convert();
let rhs = arg2.convert();
match (lhs.is_scalar().unwrap(), rhs.is_scalar().unwrap()) {
( true, false) => {
let l = tile(&lhs, rhs.dims().unwrap()).unwrap();
$help_name(&l, &rhs)
$help_name(&l, &rhs, batch)
},
(false, true) => {
let r = tile(&rhs, lhs.dims().unwrap()).unwrap();
$help_name(&lhs, &r)
$help_name(&lhs, &r, batch)
},
_ => $help_name(&lhs, &rhs),
_ => $help_name(&lhs, &rhs, batch),
}
}
)
Expand Down