Add GPU support for node graph

This commit is contained in:
Dennis
2022-08-01 23:44:18 -07:00
committed by Keavon Chambers
parent bfe21cb179
commit aa5e6f43f6
11 changed files with 232 additions and 52 deletions
+6 -2
View File
@@ -1,4 +1,5 @@
#![no_std]
#![cfg_attr(target_arch = "spirv", feature(register_attr), register_attr(spirv))]
pub mod generic;
pub mod ops;
@@ -9,12 +10,13 @@ pub mod value;
pub trait Node< 'n, Input> {
type Output : 'n;
fn eval(&'n self, input: &'n Input) -> Self::Output;
fn eval(&'n self, input: Input) -> Self::Output;
}
// TODO: Fix exec trait
pub trait Exec<'n>: Node<'n, ()> {
fn exec(&'n self) -> Self::Output {
self.eval(&())
self.eval(())
}
}
impl<'n, T: Node<'n, ()>> Exec<'n> for T {}
@@ -23,7 +25,9 @@ pub trait Cache {
fn clear(&mut self);
}
#[cfg(not(feature = "gpu"))]
extern crate alloc;
#[cfg(not(feature = "gpu"))]
impl<'n, I, O: 'n> Node<'n, I> for alloc::boxed::Box<dyn Node<'n, I, Output = O>> {
type Output = O;