The best working attemp is
#[derive(Clone, Copy, Debug, Value, PartialEq)]
#[repr(C)]
#[value_new(pub)]
pub struct CustomAdd {
i: f32,
}
impl AddExpr<CustomAddExpr> for CustomAddExpr {
type Output = Expr<CustomAdd>;
#[tracked]
fn add(self, rhs: CustomAddExpr) -> Expr<CustomAdd> {
let rhs = rhs.as_expr_from_proxy();
let self_ = self.self_.var();
*self_.i += rhs.i;
**self_
}
}
impl AddMaybeExpr<CustomAddExpr, luisa_compute::lang::types::ExprType> for Expr<CustomAdd> {
type Output = Expr<CustomAdd>;
fn __add(self, rhs: CustomAddExpr) -> Self::Output {
self.add(rhs)
}
}
fn custom_add(a: Expr<CustomAdd>, b: Expr<CustomAdd>) -> Expr<CustomAdd> {
track!(a + *b)
}
The best working attemp is