From 9476d4543f4336a66308e55f722b0b0b2bd69dd2 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 16 Mar 2023 23:46:14 -0700 Subject: Fix Phi simplification bug. (#2710) * Fix Phi simplification bug. * Fix up. * Fix. * Fix. * Fix. * Fix. * Fix. * Fix test. * Fix test. --------- Co-authored-by: Yong He --- source/slang/diff.meta.slang | 78 -------------------------------------------- 1 file changed, 78 deletions(-) (limited to 'source/slang/diff.meta.slang') diff --git a/source/slang/diff.meta.slang b/source/slang/diff.meta.slang index ada052cd8..a9b8209f3 100644 --- a/source/slang/diff.meta.slang +++ b/source/slang/diff.meta.slang @@ -1,8 +1,3 @@ -/// Modifer to mark a function for forward-mode differentiation. -/// i.e. the compiler will automatically generate a new function -/// that computes the jacobian-vector product of the original. -__attributeTarget(FunctionDeclBase) -attribute_syntax [ForwardDifferentiable] : ForwardDifferentiableAttribute; // Custom Forward Derivative Function reference __attributeTarget(FunctionDeclBase) @@ -14,8 +9,6 @@ attribute_syntax [BackwardDerivative(function)] : BackwardDerivativeAttribute; __attributeTarget(FunctionDeclBase) attribute_syntax [PrimalSubstitute(function)] : PrimalSubstituteAttribute; -__attributeTarget(FunctionDeclBase) -attribute_syntax [BackwardDifferentiable] : BackwardDifferentiableAttribute; __attributeTarget(FunctionDeclBase) attribute_syntax [ForwardDerivativeOf(function)] : ForwardDerivativeOfAttribute; @@ -33,77 +26,6 @@ attribute_syntax [DerivativeMember(memberName)] : DerivativeMemberAttribute; __attributeTarget(FunctionDeclBase) attribute_syntax [NoDiffThis] : NoDiffThisAttribute; - -/// Pair type that serves to wrap the primal and -/// differential types of an arbitrary type T. - -__generic -__magic_type(DifferentialPairType) -__intrinsic_type($(kIROp_DifferentialPairUserCodeType)) -struct DifferentialPair : IDifferentiable -{ - typedef DifferentialPair Differential; - typedef T.Differential DifferentialElementType; - - __intrinsic_op($(kIROp_MakeDifferentialPairUserCode)) - __init(T _primal, T.Differential _differential); - - property p : T - { - __intrinsic_op($(kIROp_DifferentialPairGetPrimalUserCode)) - get; - } - - property v : T - { - __intrinsic_op($(kIROp_DifferentialPairGetPrimalUserCode)) - get; - } - - property d : T.Differential - { - __intrinsic_op($(kIROp_DifferentialPairGetDifferentialUserCode)) - get; - } - - [__unsafeForceInlineEarly] - T.Differential getDifferential() - { - return d; - } - - [__unsafeForceInlineEarly] - T getPrimal() - { - return p; - } - - [__unsafeForceInlineEarly] - static Differential dzero() - { - return Differential(T.dzero(), T.Differential.dzero()); - } - - [__unsafeForceInlineEarly] - static Differential dadd(Differential a, Differential b) - { - return Differential( - T.dadd( - a.p, - b.p - ), - T.Differential.dadd(a.d, b.d)); - } - - [__unsafeForceInlineEarly] - static Differential dmul(This a, Differential b) - { - return Differential( - T.dmul(a.p, b.p), - T.Differential.dmul(a.d, b.d)); - } -}; - __generic __intrinsic_op($(kIROp_MakeDifferentialPairUserCode)) DifferentialPair diffPair(T primal, T.Differential diff); -- cgit v1.2.3