cassiersg / blis-sys2

Rust binding for BLIS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mixed precision and domain bindings

jedbrown opened this issue · comments

I'm curious if you've thought about how to expose the mixed precision/mixed domain feature in Rust.
https://github.com/flame/blis/blob/master/docs/MixedDatatypes.md

It may not be the first thing you care about binding, but I think there is some nuance worthy of discussion whenever it's a good time.

As far as I can tell, this should currently be possible to use from rust, as all required functions and constants should be exported.

Exposing BLIS API in a rustic fashion is indeed an interesting topic. It is however not the goal of this crate: I only aim to have rust declarations for all the C types and functions of BLIS. More rustic API be be better placed in another crate (which is common rust convention, AFAICT).
I would love to write that one, but I'm not sure I have time to do it. I envision two possible APIs:

  • A simple API, that merely makes the functions safe and uses proper rust types. (using slices, enum for settings, etc.). This would be rather to write, and very flexible. In such an API there would probably be still a one-to-one mapping of rust to BLIS functions for the BLIS API, which is a good fit for the BLIS typed API. It could work for the BLIS object API, but would be less convenient.
  • A more abstract API, that would provide a high level matrix API. I am however not sure that this would be useful, as it would be very close to what ndarray or nalgebra already provide. It would probably be more interesting to have ways to either call BLIS functions on ndarray/nalgebra matrices, or to use BLIS as the backend for the native operations of these crates.

I agree that it isn't the purview of this crate, but I think it's potentially a big value-add when it comes time to implement such a crate and I think it may affect how the BLIS object API is expressed here. Currently, ndarray doesn't allow mixing precisions statically, much less dynamically. The BLIS interface makes it possible to write one non-generic function and use run-time/computed parameters to decide which operations to promote/demote. That sort of flexibility isn't available in any Rust crates that I'm aware of, but would be useful in a number of scientific applications.