use crate::{pipeline, WgpuBackend};
pub struct WgpuIR {
pub pipeline: pipeline::WgpuPipeline,
}
impl vyre_driver::Executable for WgpuBackend {
fn dispatch(
&self,
program: &vyre_foundation::ir::Program,
inputs: &[vyre_driver::MemoryRef<'_>],
config: &vyre_driver::DispatchConfig,
) -> Result<Vec<vyre_driver::Memory>, vyre_driver::BackendError> {
<Self as vyre_driver::VyreBackend>::dispatch_borrowed(self, program, inputs, config)
}
}
impl WgpuBackend {
pub fn compile(
&self,
program: &vyre_foundation::ir::Program,
) -> Result<WgpuIR, vyre_driver::BackendError> {
let config = vyre_driver::DispatchConfig::default();
self.validate_with_cache(program)?;
let pipeline = crate::pipeline::WgpuPipeline::compile_with_device_queue(
program,
&config,
self.adapter_info.clone(),
self.enabled_features,
self.current_device_queue(),
self.dispatch_arena_snapshot(),
self.current_persistent_pool(),
self.pipeline_cache.clone(),
self.bind_group_layout_cache.clone(),
)?;
Ok(WgpuIR {
pipeline: (*pipeline).clone(),
})
}
pub fn dispatch_compiled(
&self,
compiled: &WgpuIR,
inputs: &[vyre_driver::MemoryRef<'_>],
config: &vyre_driver::DispatchConfig,
) -> Result<Vec<vyre_driver::Memory>, vyre_driver::BackendError> {
vyre_driver::CompiledPipeline::dispatch_borrowed(&compiled.pipeline, inputs, config)
}
}