summaryrefslogtreecommitdiff
path: root/source
AgeCommit message (Collapse)Author
2023-03-08Add support for `[PrimalSubstitute]` and `[PrimalSubstituteOf]`. (#2691)Yong He
* Add support for `[PrimalSubstitute]` and `[PrimalSubstituteOf]`. * Fix * Fix. * Cleanup. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-03-07Reuse higher-order `ResolveInvoke` logic to resolve func refs in ↵Yong He
`[*DerivativeOf]` attribs. (#2688) * Reuse higher-order `ResolveInvoke` logic to resolve func refs in [*DerivativeOf] attribs. * Add diff implementation matrix versions of binary and ternary intrinsics. * Add diff impl for legacy intrinsics. * Fix diagnostics of using non-differentiable function in a diff operator. * Add diff implementation for `determinant`. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-03-01Implement derivatives for HLSL intrinsics. (#2684)Yong He
* Implement derivatives for HLSL intrinsics. * Vector intrinsics. * Add all intrinsics. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-03-01Improve diagnostic on differentiablitiy check. (#2687)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2023-02-28AD: Fixed do-while loops (#2683)Sai Praveen Bangaru
* WIP: Fix for do-while loops * Added a somewhat hacky fix for do-while loops * Redid the indexed region map builder step to fix issue with the nested loops test * rename * Used managed pointers
2023-02-28Add `SourceBlobWithPathInfoArtifactRepresentation`. (#2682)Yong He
2023-02-27Diagnose on storing differentiable value into non-differentiable location. ↵Yong He
(#2681)
2023-02-27More fixes for reverse-mode on complicated loops (#2675)Sai Praveen Bangaru
* Multiple fixes to get various loop tests to pass. * Create reverse-nested-loop.slang * Fix for variables becoming inaccessible during cfg normalization * Removed comments and moved break-branch-normalization to eliminateMultiLevelBreaks * Fix. * Override liveness tests
2023-02-27Detect and deduplicate read-only resource access. (#2680)Yong He
* Detect and deduplicate read-only resource access. * Fix tests. * Fix tests. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-02-24Added support for `kIROp_Select` (#2679)Sai Praveen Bangaru
2023-02-24Support dynamic dispatch a backward differentiable function. (#2678)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2023-02-24Fix differential type registration through non-differentiable type. (#2677)Yong He
* Fix differential type registration through non-differentiable type. * More fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-02-24More control flow simplifications. (#2673)Yong He
* More control flow and Phi param simplifications. * Fix. * Fix gcc error. * Fix. * More IR cleanup. * Fix bug in phi param dce + ifelse simplify. * Propagate and DCE side-effect-free functions. * Enhance CFG simplifcation to remove loops with no side effects. * Fix. * Fixes. * Fix tests. Add [__AlwaysFoldIntoUseSite] for rayPayloadLocation. * More cleanup. * Fixes. * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-02-22Fixed hoisting of intermediate array & context vars (#2674)Sai Praveen Bangaru
Also added legalization for loops
2023-02-22Reverse-mode AD fixes for loops with non-trivial break region (#2671)Sai Praveen Bangaru
* Fix crash when applying autodiff to functions with no arguments * Fixes for loops where the break region is non-trivial * Minor fix * Implement array legalization correctly. * Fix array legalization. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-02-21Fix transposeCall. (#2669)Yong He
* Modify control-flow test case * Update reverse-control-flow-3.slang * Fix `transposeCall`. * Fix. --------- Co-authored-by: Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> Co-authored-by: Yong He <yhe@nvidia.com>
2023-02-21Added support for simple while loops (#2667)Sai Praveen Bangaru
* Added support for simple while loops * Fix support for while loops by changing logic to grab the loop update block
2023-02-20Miscellaneous backward autodiff fixes. (#2665)Yong He
* Fix differentiable type registration * Fix use of non-differentiable return value in a differentiable func. * Fix use of primal inst that does not dominate the diff block. * Fix primal inst hoisting, and add missing type legalization logic. * Make `detach` defined on all differentiable T. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-02-20Add static for loop iteration inference. (#2659)Yong He
2023-02-17Allocate N+1 arrays instead of N to avoid out-of-bounds access when ↵Sai Praveen Bangaru
unzipping loops (#2663)
2023-02-17AD: More legacy type handling cleanup + user-defined reverse-mode fix (#2662)Sai Praveen Bangaru
* WIP: Remove all legacy type checking * Fixed issue with user-defined backward derivatives not bypassing the AD process --------- Co-authored-by: Yong He <yonghe@outlook.com>
2023-02-17AD: Remove the original loop condition upon inversion (#2661)Sai Praveen Bangaru
* Remove the original condition upon loop inversion (it's redundant, and causes out-of-bounds accesses) * minor fix (also removed the first loop check skip) * Cleanup unused insts * minor comment fix
2023-02-17Fixed crash when lowering IR for no_diff struct member. (#2658)Yong He
* Fixed crash when lowering IR for no_diff struct member. * Improve `setInsertBeforeOrdinaryInst` and `setInsertAfterOrdinaryInst`. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-02-17Cleaned up legacy differential type handling + type casting bugfixes (#2660)Sai Praveen Bangaru
2023-02-17Proper reverse-mode loop handling with splitting + inversion steps (#2656)Sai Praveen Bangaru
* Halfway to loop inversion * More progress towards proper loop inversion * More progress towards inverse insts. Only thing left is adding `counter>=0` at the right place * More fixes for inversion step. * Lots more fixes, added primal inst 'hoisting' mechanism as the central method that ensures primal values are placed in the right spot * Loop inversion is now functional * Cleaned up commented code * rename diffCounterVar -> diffCounterParam * minor update * removed some comments and commented code * Switch `IRBuilder(sharedIRBuilder)` to `IRBuilder(moduleInst)`
2023-02-16Remove `SharedIRBuilder`. (#2657)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2023-02-16Overhaul global inst deduplication and cpp/cuda backend. (#2654)Yong He
* Overhaul global inst deduplication and cpp/cuda backend. * Update IR documentation. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-02-15Treat user defined backward derivative function as non differentiable. (#2650)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2023-02-15Upgrade GLSLANG 12.0.0 (#2651)jsmall-nvidia
* #include an absolute path didn't work - because paths were taken to always be relative. * Update to glslang 12.0.0. Update SPIRV-Tools SPIRV-Headers.
2023-02-14Preliminary debugBreak support (#2647)jsmall-nvidia
* #include an absolute path didn't work - because paths were taken to always be relative. * Preliminary support for debug break. * Add C++ debug break support. Add details about usage. * Improve debug break test details. * Make HLSL output a comment about no support. * Handle specialize for target assert, without a body if it has spv_instruction/target intrinsic
2023-02-13Various auto-diff bug fixes. (#2646)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2023-02-13Eliminate `continue` to allow unrolling any loops. (#2645)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2023-02-13Add Loop Unrolling Pass. (#2644)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2023-02-11Take into account existing initializer list type when performing coercions ↵Ellie Hermaszewska
(#2641) Fixes https://github.com/shader-slang/slang/issues/2189
2023-02-10Fix several autodiff bugs. (#2643)Yong He
2023-02-10Fix checking of `[BackwardDerivativeOf]` attribute. (#2640)Yong He
* Fix checking of `[BackwardDerivativeOf]` attribute. * Fix crash in `canInstHaveSideEffectAtAddress`. * Fix. * Revert fix. * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-02-09Reverse-mode Loop Support (#2635)Sai Praveen Bangaru
* Full loop support now working. MaxItersAttr in progress * Lookup table updates? * Fixed the max iters decoration * Minox fixes & remove superfluous code * fixup warnings * Revert "Lookup table updates?" This reverts commit 7d9b0793fb5239f31d1155776e846dcf1892d8d9. * Update 07-autodiff.md * Change maxiters to MaxIters * Added asserts * Update 07-autodiff.md
2023-02-09Fixed derivatives for kIROp_Neg and kIROp_Div, added another test (#2639)Sai Praveen Bangaru
2023-02-09Use stable sort in generation of lookup tables (#2638)Ellie Hermaszewska
* Add Slang::List::stableSort * Use stable sort in generation of lookup tables * Disable newline translation when writing lookup tables
2023-02-07Add backward derivatives for functions in diff.meta.slang (#2633)winmad
* WIP: start adding backward derivatives * Overhaul `transposeParameterBlock` to support `inout` params. * Small bug fixes. * Bug fix on differentiable intrinsic specialization. * Fixes. * Run autodiff tests on CPU. * Clean up. * Overhaul `transposeParameterBlock` to support `inout` params. * Small bug fixes. * Bug fix on differentiable intrinsic specialization. * Fixes. * Run autodiff tests on CPU. * Clean up. * More bug fixes., * WIP: working on detach * Arithmetic simplifications and more IR clean up logic. * WIP: adding detach and abs * Fix detach and abs * Fix. * Add IR transform pass for cleaner code emit. * Fix test cases. * Fix type system logic for reference type. * Add backward derivatives for functions that already have forward derivatives * Fix changes --------- Co-authored-by: Yong He <yhe@nvidia.com> Co-authored-by: Lifan Wu <lifanw@nvidia.com>
2023-02-07Arithmetic simplifications and more IR clean up logic. (#2632)Yong He
2023-02-06Fix crash when processing nested switch. (#2624)Yong He
* Fix crash when processing nested switch. * Clean up. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-02-04Patch transcription of `inout` non differentiable params. (#2623)Yong He
2023-02-03Overhaul `transposeParameterBlock` to support `inout` params. (#2621)Yong He
* Overhaul `transposeParameterBlock` to support `inout` params. * Small bug fixes. * Bug fix on differentiable intrinsic specialization. * Fixes. * Run autodiff tests on CPU. * Clean up. * More bug fixes., * Add test coverage on inout param. * Fix language server hinting for transcribed mutable params. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-02-03Small fixes around repro (#2622)jsmall-nvidia
* #include an absolute path didn't work - because paths were taken to always be relative. * Fix issues in repo due to C++ expression evaluation ordering is undefined.
2023-02-03Use SPIR-V opcode names rather than numbers (#2571)Ellie Hermaszewska
* s/emititng blobal/emitting global * Use SPIR-V opcode names rather than numbers * regenerate Visual Studio project files * Use names for extended SPIR-V GLSL instructions * Add missing operand for SPIR-V extended instruction * Add warning aginst modifying generated hashing files * Squash warnings on MSVC
2023-02-01Support `out` parameters in backward differentiation. (#2619)Yong He
* Support `out` parameters in backward differentiation. * Fixes. * Fix cleanup. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-01-31Patched support for multi-return and fallthrough if-else with break stmts ↵Sai Praveen Bangaru
(#2617)
2023-01-30Add transposition logic for constructor opcodes. (#2618)Yong He
* Add transposition logic for constructor opcodes. * Fix. * Add language server regression test. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-01-30Make ArrayExpressionType a DeclRefType and define its autodiff extension in ↵Yong He
stdlib. (#2615) * Allow array parameters in forward diff. * Use type canonicalization instead of coersion. * Reimplement array type. * Fix. * Update test case. --------- Co-authored-by: Yong He <yhe@nvidia.com>