Skip to content

Commit

Permalink
fixed _deref_proxy, how wasn't it crashing...
Browse files Browse the repository at this point in the history
  • Loading branch information
shiinamiyuki committed Sep 23, 2023
1 parent 8308a19 commit b06f49e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
4 changes: 2 additions & 2 deletions luisa_compute/src/lang/ops/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ macro_rules! impl_simple_binop {
impl_ops_trait!([X: Linear] MinMaxExpr[MinMaxThis] for Expr<X> where [X::Scalar: Numeric] {
type Output = Expr<X::WithScalar<X::Scalar>>;

fn max_expr[_max_expr](self, other) { Func::Max.call2(self, other) }
fn min_expr[_min_expr](self, other) { Func::Min.call2(self, other) }
fn max_[_max_](self, other) { Func::Max.call2(self, other) }
fn min_[_min_](self, other) { Func::Min.call2(self, other) }
});

impl_ops_trait!([X: Linear] ClampExpr[ClampThis] for Expr<X> where [X::Scalar: Numeric] {
Expand Down
12 changes: 6 additions & 6 deletions luisa_compute/src/lang/ops/spread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,25 +213,25 @@ where
Expr<T::Join>: MinMaxThis,
{
type Output = <Expr<T::Join> as MinMaxThis>::Output;
fn min_expr(self, other: S) -> Self::Output {
Expr::<T::Join>::_min_expr(Self::lift_self(self), Self::lift_other(other))
fn min_(self, other: S) -> Self::Output {
Expr::<T::Join>::_min_(Self::lift_self(self), Self::lift_other(other))
}
fn max_expr(self, other: S) -> Self::Output {
Expr::<T::Join>::_max_expr(Self::lift_self(self), Self::lift_other(other))
fn max_(self, other: S) -> Self::Output {
Expr::<T::Join>::_max_(Self::lift_self(self), Self::lift_other(other))
}
}

pub fn min<T, S>(x: T, y: S) -> <T as MinMaxExpr<S>>::Output
where
T: MinMaxExpr<S>,
{
x.min_expr(y)
x.min_(y)
}
pub fn max<T, S>(x: T, y: S) -> <T as MinMaxExpr<S>>::Output
where
T: MinMaxExpr<S>,
{
x.max_expr(y)
x.max_(y)
}

impl<T: Value, S, U> ClampExpr<S, U> for Expr<T>
Expand Down
6 changes: 3 additions & 3 deletions luisa_compute/src/lang/ops/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ macro_rules! assignop_trait {
ops_trait!(MinMaxExpr<T>[MinMaxThis] {
type Output;

fn max_expr[_max_expr](self, other: T);
fn min_expr[_min_expr](self, other: T);
fn max_[_max_](self, other: T);
fn min_[_min_](self, other: T);
});

ops_trait!(ClampExpr<A, B>[ClampThis] {
Expand Down Expand Up @@ -211,7 +211,7 @@ pub trait IntExpr {

pub trait FloatExpr: Sized {
type Bool;

fn ceil(&self) -> Self;
fn floor(&self) -> Self;
fn round(&self) -> Self;
Expand Down
6 changes: 2 additions & 4 deletions luisa_compute/src/lang/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ impl<T: Value> Expr<T> {
let node = __current_scope(|s| s.bitcast(self.node(), ty));
Expr::<S>::from_node(node)
}
pub fn _type_tag(&self)->TypeTag<T> {
pub fn _type_tag(&self) -> TypeTag<T> {
TypeTag(PhantomData)
}
}
Expand Down Expand Up @@ -350,9 +350,7 @@ impl<T: Value> AtomicRef<T> {
}

pub fn _deref_proxy<P: VarProxy>(proxy: &P) -> &Expr<P::Value> {
unsafe { &*(proxy as *const P as *const Var<P::Value>) }
.load()
._ref()
proxy.as_var_from_proxy().load()._ref()
}

#[macro_export]
Expand Down

0 comments on commit b06f49e

Please sign in to comment.