Skip to content

Operating overloading on custom type is broken #19

@shiinamiyuki

Description

@shiinamiyuki

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)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions