Skip to content

Better Arrayfire Expressions Syntax #45

@adamcavendish

Description

@adamcavendish

I am thinking of a better way of expressing arrayfire expressions in rust, however still needs some work on the design.

We can create macros describing an arrayfire expressions, like this:

let dims = af::Dim4::new(&[10, 10, 1, 1]);
let a = af::randu(dims, Aftype::F32)
let result = af::expression!(
    |expr, err| println!("'{}' Calculation failure, error: {}", expr, err),
    af::sin(1) / a + a);

let result = af::retry!(
    3,
    |expr, err| println!("'{}' Calcuation failure, error: {}", expr, err),
    af::retry_expression!(af::sin(1) / a + a));

Most of the time I'm quite bored with a lot of and_then appearing in my arrayfire-rust code, and creating a lot of disambiguation in expresstions.

However, the with the error appearing, generally people will:

  1. print the error, save the state and calculated results and let it panic. Then, let other daemon scripts restart the program.
  2. retry the calculation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions