pub struct Program {
pub stmts: Vec<Expr>,
pub params: Vec<ParamSpec>,
pub display_src: String,
pub agreement: Agreement,
pub fmt: FmtOpts,
pub rules: Rules,
}Expand description
A compiled program: immutable, reusable, holds no data bindings.
Fields§
§stmts: Vec<Expr>§params: Vec<ParamSpec>§display_src: StringThe source as the user would recognise it (interpolations shown as
{name}); all spans point into this string.
agreement: Agreement§fmt: FmtOpts§rules: RulesThe dialect this program was compiled under, resolved.
Implementations§
Source§impl Program
impl Program
Sourcepub fn run(
&self,
args: &[Array],
out: &mut dyn FnMut(&str),
) -> Result<Option<Array>>
pub fn run( &self, args: &[Array], out: &mut dyn FnMut(&str), ) -> Result<Option<Array>>
Execute with one value per parameter, in params order.
Returns None when the last sentence yields no value.
Sourcepub fn run_on(
&self,
device: &Device,
args: &[Array],
out: &mut dyn FnMut(&str),
) -> Result<Option<Array>>
pub fn run_on( &self, device: &Device, args: &[Array], out: &mut dyn FnMut(&str), ) -> Result<Option<Array>>
Execute with the fused kernels placed on device.
Placement is not binding: the program, its data and its diagnostics
are the same whatever device is named here. What a device will not
take runs on the CPU, and explain says which and why.
pub fn render_error(&self, e: &Error) -> String
Sourcepub fn explain(&self, args: Option<&[Array]>) -> String
pub fn explain(&self, args: Option<&[Array]>) -> String
What this expression became, as text: one section per sentence, giving the structure the frontend and the fusion pass produced.
With one value per parameter (or none, for a program that takes none) the program is also run, and every node is annotated with the shape and dtype it produced — a fused node with whether its kernel ran, and why not when it did not. The run is the ordinary one, so it has the ordinary effects; output it makes is discarded here, and an error stops the annotations and is reported at the end.
Sourcepub fn explain_on(&self, device: &Device, args: Option<&[Array]>) -> String
pub fn explain_on(&self, device: &Device, args: Option<&[Array]>) -> String
Program::explain, with the run placed on device: every fused
node then also says where its arithmetic happened, and why it was
not the device when it was not.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Program
impl !UnwindSafe for Program
impl Freeze for Program
impl Send for Program
impl Sync for Program
impl Unpin for Program
impl UnsafeUnpin for Program
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more