Skip to content

Commit 33d5a5b

Browse files
authored
Merge branch 'master' into conform-integer-literals
2 parents b06526b + 0d92d72 commit 33d5a5b

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

docs/user-guide/07-autodiff.md

+3
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ interface IDifferentiablePtrType
167167
}
168168
```
169169

170+
> #### Note ####
171+
> Support for `IDifferentiablePtrType` is still experimental.
172+
170173
Types should not conform to both `IDifferentiablePtrType` and `IDifferentiable`. Such cases will result in a compiler error.
171174

172175

source/slang/core.meta.slang

+25-11
Original file line numberDiff line numberDiff line change
@@ -416,13 +416,18 @@ void __requireGLSLExtension(constexpr String preludeText);
416416
__intrinsic_op($(kIROp_StaticAssert))
417417
void static_assert(constexpr bool condition, NativeString errorMessage);
418418

419-
/// Interface to denote types as differentiable.
420-
/// Allows for user-specified differential types as
421-
/// well as automatic generation, for when the associated type
422-
/// hasn't been declared explicitly.
423-
/// Note that the requirements must currently be defined in this exact order
424-
/// since the auto-diff pass relies on the order to grab the struct keys.
419+
/// Represents a type that is differentiable for the purposes of automatic differentiation.
425420
///
421+
/// Implemented by builtin floating-point scalar types (`float`, `half`, `double`)
422+
///
423+
/// vector<T, N>, matrix<T, N, M> and Array<T, N> automatically conform to
424+
/// `IDifferentiable` if `T` conforms to `IDifferentiable`.
425+
///
426+
/// @remarks Types that implement `IDifferentiable` can be used with the automatic differentiation
427+
/// primitives `bwd_diff` and `fwd_diff` to load and store gradients of parameters.
428+
/// @remarks This interface supports automatic synthesis of requirements. A struct that conforms to `IDifferentiable`
429+
/// will have its `Differential`, `dzero()` and `dadd()` methods automatically synthesized based on its fields, if
430+
/// they are not already defined.
426431
__magic_type(DifferentiableType)
427432
interface IDifferentiable
428433
{
@@ -446,9 +451,13 @@ interface IDifferentiable
446451
static Differential dmul(T, Differential);
447452
};
448453

449-
/// Represents a type that supports differentiation operations for pointer types.
450-
/// This interface is used to define operations that are specific to pointer types
451-
/// in the context of automatic differentiation.
454+
/// @experimental
455+
///
456+
/// Represents a type that supports differentiation operations for pointers, buffers and
457+
/// any other types
458+
///
459+
/// @remarks Support for this interface is still experimental and subject to change.
460+
///
452461
__magic_type(DifferentiablePtrType)
453462
interface IDifferentiablePtrType
454463
{
@@ -458,8 +467,9 @@ interface IDifferentiablePtrType
458467

459468

460469
/// Pair type that serves to wrap the primal and
461-
/// differential types of an arbitrary type T.
462-
470+
/// differential types of a differentiable value type
471+
/// T that conforms to `IDifferentiable`.
472+
///
463473
__generic<T : IDifferentiable>
464474
__magic_type(DifferentialPairType)
465475
__intrinsic_type($(kIROp_DifferentialPairUserCodeType))
@@ -528,6 +538,10 @@ struct DifferentialPair : IDifferentiable
528538
}
529539
};
530540

541+
/// Pair type that serves to wrap the primal and
542+
/// differential types of a differentiable pointer type
543+
/// T that conforms to `IDifferentiablePtrType`.
544+
///
531545
__generic<T : IDifferentiablePtrType>
532546
__magic_type(DifferentialPtrPairType)
533547
__intrinsic_type($(kIROp_DifferentialPtrPairType))

0 commit comments

Comments
 (0)