From 0d92d72981b7883f7aab509a640b4f52dc55a819 Mon Sep 17 00:00:00 2001 From: Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> Date: Sun, 1 Dec 2024 17:57:53 -0500 Subject: [Docs] Minor fixes to auto-diff documentation (#5621) * Minor fixes to AD documentation * Add a note warning about experimental behavior * Update vulkan --------- Co-authored-by: Ellie Hermaszewska Co-authored-by: Yong He --- source/slang/core.meta.slang | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'source') diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang index 817e3c39d..a9d53162c 100644 --- a/source/slang/core.meta.slang +++ b/source/slang/core.meta.slang @@ -416,13 +416,18 @@ void __requireGLSLExtension(constexpr String preludeText); __intrinsic_op($(kIROp_StaticAssert)) void static_assert(constexpr bool condition, NativeString errorMessage); -/// Interface to denote types as differentiable. -/// Allows for user-specified differential types as -/// well as automatic generation, for when the associated type -/// hasn't been declared explicitly. -/// Note that the requirements must currently be defined in this exact order -/// since the auto-diff pass relies on the order to grab the struct keys. +/// Represents a type that is differentiable for the purposes of automatic differentiation. /// +/// Implemented by builtin floating-point scalar types (`float`, `half`, `double`) +/// +/// vector, matrix and Array automatically conform to +/// `IDifferentiable` if `T` conforms to `IDifferentiable`. +/// +/// @remarks Types that implement `IDifferentiable` can be used with the automatic differentiation +/// primitives `bwd_diff` and `fwd_diff` to load and store gradients of parameters. +/// @remarks This interface supports automatic synthesis of requirements. A struct that conforms to `IDifferentiable` +/// will have its `Differential`, `dzero()` and `dadd()` methods automatically synthesized based on its fields, if +/// they are not already defined. __magic_type(DifferentiableType) interface IDifferentiable { @@ -446,9 +451,13 @@ interface IDifferentiable static Differential dmul(T, Differential); }; -/// Represents a type that supports differentiation operations for pointer types. -/// This interface is used to define operations that are specific to pointer types -/// in the context of automatic differentiation. +/// @experimental +/// +/// Represents a type that supports differentiation operations for pointers, buffers and +/// any other types +/// +/// @remarks Support for this interface is still experimental and subject to change. +/// __magic_type(DifferentiablePtrType) interface IDifferentiablePtrType { @@ -458,8 +467,9 @@ interface IDifferentiablePtrType /// Pair type that serves to wrap the primal and -/// differential types of an arbitrary type T. - +/// differential types of a differentiable value type +/// T that conforms to `IDifferentiable`. +/// __generic __magic_type(DifferentialPairType) __intrinsic_type($(kIROp_DifferentialPairUserCodeType)) @@ -528,6 +538,10 @@ struct DifferentialPair : IDifferentiable } }; +/// Pair type that serves to wrap the primal and +/// differential types of a differentiable pointer type +/// T that conforms to `IDifferentiablePtrType`. +/// __generic __magic_type(DifferentialPtrPairType) __intrinsic_type($(kIROp_DifferentialPtrPairType)) -- cgit v1.2.3