Files
Graphite/node-graph/gstd/src/value.rs
Dennis Kobert 3c2d371173 Graphene CLI + quantization research (#1320)
* Implement skeleton for graphene-cli

* Configure gpu surface on non wasm32 targets

* Create window with full hd size

* Create window using the graphen-cli

* Use window size for surface creation

* Reuse surface configuration

* Reduce window size for native applications to 800x600

* Add compute pipeline test

* Poll wgpu execution externally

* Remove cache node after texture upload

* Add profiling instructions

* Add more debug markers

* Evaluate extract node before flattening the network

* Reenable hue saturation node for compilation

* Make hue saturation node work on the gpu + make f32 default for user inputs

* Add version of test files without caching

* Only dispatch each workgroup not pixel

* ICE

* Add quantization to gpu code

* Fix quantization

* Load images at graph runtime

* Fix quantization calculation

* Feature gate quantization

* Use git version of autoquant

* Add license to `graphene-cli`

* Fix graphene-cli test case

* Ignore tests on non unix platforms

* Fix flattening test
2023-07-04 17:04:09 +02:00

47 lines
1.1 KiB
Rust

use core::marker::PhantomData;
pub use graphene_core::value::*;
use graphene_core::Node;
use dyn_any::DynAny;
pub struct AnyRefNode<'n, N: Node<'n>>(N, PhantomData<&'n ()>);
impl<'n, N: Node<'n, Output = &'n O>, O: DynAny<'n> + 'n> Node<'n> for AnyRefNode<'n, N> {
fn eval(&'n self) -> &'n (dyn DynAny<'n>) {
let value: &O = self.0.eval();
value
}
}
impl<'n, N: Node<'n, Output = &'n O>, O: 'n + ?Sized> AnyRefNode<'n, N> {
pub fn new(n: N) -> AnyRefNode<'n, N> {
AnyRefNode(n, PhantomData)
}
}
pub struct StorageNode<'n>(&'n dyn Node<'n, Output = &'n dyn DynAny<'n>>);
impl<'n> Node<'n> for StorageNode<'n> {
fn eval(&'n self) -> &'n (dyn DynAny<'n>) {
self.0.eval()
}
}
impl<'n> StorageNode<'n> {
pub fn new<N: Node<'n, Output = &'n dyn DynAny<'n>>>(n: &'n N) -> StorageNode<'n> {
StorageNode(n)
}
}
#[derive(Default)]
pub struct AnyValueNode<'n, T>(T, PhantomData<&'n ()>);
impl<'n, T: 'n + DynAny<'n>> Node<'n> for AnyValueNode<'n, T> {
fn eval(&'n self) -> &'n dyn DynAny<'n> {
&self.0
}
}
impl<'n, T> AnyValueNode<'n, T> {
pub const fn new(value: T) -> AnyValueNode<'n, T> {
AnyValueNode(value, PhantomData)
}
}