diff options
| author | kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> | 2025-09-23 11:06:44 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-23 11:06:44 -0500 |
| commit | 21c663605330d629e9022314a4720b86b017f295 (patch) | |
| tree | fcbfadeddd8f1d68f1034f89288c960b6ba7294a /tests | |
| parent | 7740f7905fdebebdbe22011787d432b385f4cd9d (diff) | |
Lookup refactor (#8467)
Close #8201.
This PR unify the lowering logic for LookupDeclRef of an interface
requirement. We will always lower this AST node to a
LookupWitness IR. The key of this IR is the special witnessTableType
`ThisTypeWitness`, this witness Table is simply a wrapper for an
interface type. Our current specialization pass doesn't handle this kind
of LookupWitness IR at all, so we will also add the specialization of
this_type IR as well.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/autodiff/differential-ptr-pair-with-associate-type.slang | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/autodiff/differential-ptr-pair-with-associate-type.slang b/tests/autodiff/differential-ptr-pair-with-associate-type.slang new file mode 100644 index 000000000..870660b84 --- /dev/null +++ b/tests/autodiff/differential-ptr-pair-with-associate-type.slang @@ -0,0 +1,42 @@ +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute -shaderobj -output-using-type +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-cuda -compute -shaderobj -output-using-type +interface IFoo<T> +{ + associatedtype Parameters : IDifferentiablePtrType; + property DifferentialPtrPair<Parameters> parametersDual { get; } +} + +extension<T: __BuiltinFloatingPointType> T: IDifferentiablePtrType +{ + typealias Differential = T; +} + +struct Foo<T:__BuiltinFloatingPointType> : IFoo<T> +{ + typealias Parameters = Array<T, 1>; + property DifferentialPtrPair<Parameters> parametersDual + { + get + { + Parameters primal = {T(1)}; + Parameters diff = {T(2)}; + return DifferentialPtrPair<Parameters>(primal, diff); + } + } +} + +//TEST_INPUT:ubuffer(data=[0 0], stride=4):out,name=output +RWStructuredBuffer<float> output; + +[shader("compute")] +[numthreads(1, 1, 1)] +void computeMain() +{ + Foo<float> foo; + let res = foo.parametersDual; + output[0] = res.p[0]; + output[1] = res.d[0]; + + // CHECK: 1.0 + // CHECK: 2.0 +} |
