diff options
| author | Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> | 2023-09-19 18:51:24 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-19 18:51:24 -0400 |
| commit | 739c3a7b53dc6489065fcd5e9f0a04370c5f9c8f (patch) | |
| tree | 593c86cbc184476479c66554cc6784b454bdec66 /tests/compute | |
| parent | 359fdc9d556b4c493c588c5b8f93df85933634f8 (diff) | |
Added `[AutoPyBindCUDA]` for automatic kernel binding + `[PyExport]` for exporting type information (#3209)
* Initial: add a DiffTensor impl
* Auto-binding and diff tensor implementations now work
* Refactored diff-tensor implementation + added py-export for struct types
* Cleanup
* Update slang-ir-pytorch-cpp-binding.cpp
* Updated test names
* Update autodiff-data-flow.slang.expected
* Add more versions of load/store & default generic args for DiffTensorView.
* Add diagnostic for default generic arg and more tests
* Add more `[AutoPyBind]` tests
Diffstat (limited to 'tests/compute')
| -rw-r--r-- | tests/compute/generic-default-arg.slang | 53 | ||||
| -rw-r--r-- | tests/compute/generic-default-arg.slang.expected.txt | 4 |
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/compute/generic-default-arg.slang b/tests/compute/generic-default-arg.slang new file mode 100644 index 000000000..8762f5e8a --- /dev/null +++ b/tests/compute/generic-default-arg.slang @@ -0,0 +1,53 @@ +//TEST(compute):COMPARE_COMPUTE: -shaderobj +//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj + +// Check that user code can declare and use a generic +// `struct` type. + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +interface ITest +{ + int doThing(int x); +}; + +struct Impl1 : ITest +{ + int doThing(int x) + { + return x * 2; + } +}; + +struct Impl2 : ITest +{ + int doThing(int x) + { + return x * 3; + } +}; + +__generic<T : ITest = Impl1> +struct GenStruct +{ + T obj; +}; + +int test(GenStruct gs, int val) +{ + return gs.obj.doThing(val); +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int tid = dispatchThreadID.x; + + int outVal = 0; + + GenStruct<Impl1> gs; + outVal += test(gs, tid); + + outputBuffer[tid] = outVal; +}
\ No newline at end of file diff --git a/tests/compute/generic-default-arg.slang.expected.txt b/tests/compute/generic-default-arg.slang.expected.txt new file mode 100644 index 000000000..e1e8ccec4 --- /dev/null +++ b/tests/compute/generic-default-arg.slang.expected.txt @@ -0,0 +1,4 @@ +0 +2 +4 +6 |
