summaryrefslogtreecommitdiff
path: root/source
AgeCommit message (Collapse)Author
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>
2023-01-30Overhauled reverse-mode control flow handling (#2608)Sai Praveen Bangaru
* Added switch-case support; fixed non-diff parameter transposition * Made region propagation much more robust. Partial loop unzip implementation * WIP: Added most loop handling code, and a test. Still untested * Added CFG Normalization pass + CFG Reversal Pass + Loop Unzipping + most loop transcription * Add single-iter-loop test. * proj files * removed comments * Update reverse-loop.slang * Removed out-of-date code * Disabled IR validation during constructSSA phase of normalizeCFG. constructSSA now reuses sharedBuilder * Moved normalizeCFG() call to prepareFuncForBackwardDiff()
2023-01-27Register allocation during phi elimination. (#2613)Yong He
* Register allocation during phi elimination. * Enhance the test case. * Cleanup line breaks in test case. * remove unncessary line break changes. * More cleanups. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-01-27Add ASAN support + fixes (#2614)skallweitNV
* Add ASAN support to premake * Fix StringRepresentation when ASAN is enabled * Fix deep recursion in slang-generate * Fix hello-world example * Fix gpu-printing example * Linux fix * Try fixing linux * Add missing include
2023-01-25Unify UpdateField and UpdateElement with access chain. (#2611)Yong He
* Unify UpdateField and UpdateElement with access chain. * Fix warnings. Co-authored-by: Yong He <yhe@nvidia.com>
2023-01-25Cleanup IR representation of interface member derivative. (#2610)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2023-01-24Reimplement address elimination. (#2605)Yong He
* Reimplement address elimination pass. * Fix error. * Update test references. Co-authored-by: Yong He <yhe@nvidia.com>
2023-01-24Small fix for "static" in doc output (#2606)jsmall-nvidia
* #include an absolute path didn't work - because paths were taken to always be relative. * Upgrade to slang-llvm-13.x-33 * Kick - as build failed on download egress. * Output "static" on methods in doc output.
2023-01-23Full address insts elimination for backward autodiff. (#2604)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2023-01-19Add diagnostic for calling non-bwd-diff func from bwd-diff func. (#2602)Yong He
2023-01-17First custom backward-derivative test case working. (#2598)Yong He
2023-01-17Add `set` to spirv_instruction (#2597)jsmall-nvidia
2023-01-17Added switch-case support; fixed non-diff parameter transposition (#2596)Sai Praveen Bangaru
2023-01-15Switched to a much simpler method to transpose control flow, nested control ↵Sai Praveen Bangaru
flow works now (#2595)
2023-01-14Support custom backward derivative attribute. (#2594)Yong He
2023-01-14Fixes for crash when inlining at global scope (#2593)Theresa Foley
* Fixes for crash when inlining at global scope Recent changes to the way inlining is implemented in the Slang compiler have broken certain scenarios involving `static const` declarations. The basic problem is that the initial-value expression for a `static const` gets lowered into IR code at the global scope of a module, and if that code includes `call`s to stdlib operations marked `forceInlineEarly`, then we end up trying to apply inlining to code at module scope. The current inlining operation assumes that all `call`s are in basic blocks, and that the correct way to do inlining involves splitting those blocks. This change adds logic to detect when the callee at a call site to be inlined consists of a single basic block ending in a `return`, and in that case it invokes specialized inlining logic that doesn't split basic blocks and doesn't need to care if the original `call` is in a basic block. Thus we are able to inline calls to single-basic-block `forceInlineEarly` functions called as part of the initialization for global-scope `static const` variables. This logic does *not* solve the problem of calls to multi-block `forceInlineEarly` functions from the global scope. Such calls cannot really be inlined. A secondary problem that arises when inlining such calls is that the callee might include local temporaries (`var` instructions) that are read and written (`load`s and `store`s), and none of those instructions should be allowed at the global scope. In the case of the functions being inlined here, the `load`/`store` operations are superfluous, and should be cleaned up by our SSA pass. The only reason that they seem to *not* be getting cleaned up in the case that was been triggering crashes is that the callee is a generic. The current logic for the SSA pass was skipping the bodies of generic functions, so they would not be cleaned up. This change enables the SSA pass to apply to the bodies of generic functions, and also ensures that SSA cleanups are applied *before* any `forceInlineEarly` functions get inlined. * fixup: liveness test outputs
2023-01-13Frontend work for `[BackwardDerivative]` and `[BackwardDerivativeOf]`. (#2589)Yong He
* Frontend work for `[BackwardDerivative]` and `[BackwardDerivativeOf]`. * Fix clang issue. * Fix. * fix gcc issue * fix formatting. Co-authored-by: Yong He <yhe@nvidia.com>
2023-01-12Fix issue around linking/obfuscation (#2588)jsmall-nvidia
* #include an absolute path didn't work - because paths were taken to always be relative. * Work around for some issue seen with a repro. * Small improvement in doing IDifferentable check. * Fix around obfuscation linkage.
2023-01-11Make backward differentiation work with generics. (#2586)Yong He
* Make backward differentiation work with generics. * Fix. * Another fix. * More fix. Co-authored-by: Yong He <yhe@nvidia.com>
2023-01-10Small fixes around repro loading/autodiff (#2585)jsmall-nvidia
* #include an absolute path didn't work - because paths were taken to always be relative. * Work around for some issue seen with a repro. * Small improvement in doing IDifferentable check.
2023-01-10Nested bwd-diff func call context save/restore. (#2584)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2023-01-06Fix small issue around emitInterpolationModifiersImpl when layout is ↵jsmall-nvidia
nullptr. (#2583) * #include an absolute path didn't work - because paths were taken to always be relative. * Fix output when layout is nullptr in emitInterpolatioModifiersImpl
2023-01-06Split bwd_diff op into separate ops for primal and propagate func. (#2582)Yong He
* Split bwd_diff op into separate ops for primal and propagate func. * Fix. * Download swiftshader with github actions instead of curl on linux. * Fix github action. Co-authored-by: Yong He <yhe@nvidia.com>
2023-01-04Multi-block reverse-mode autodiff (#2576)Sai Praveen Bangaru
* Initial multi-block implementation * Implemented multi-block reverse-mode (without loops) * Added logic to remove block-level decorations to avoid confusing IR simplification passes * Fixed issues with block-level decorations during IR simplification by removing them prior to simplification. Co-authored-by: Yong He <yonghe@outlook.com>
2023-01-04Avoid dots in auto-detected filename extensions (#2566)Ellie Hermaszewska
Supersedes #2532
2023-01-04Add format checking attributes on printf-like functions (#2570)Ellie Hermaszewska
* Add format checking attributes on printf-like functions * Don't use printf format attributes on msvc Where they are not supported
2022-12-21Further unify the autodiff passes. (#2574)Yong He
* Further unify the autodiff passes. * Fix clang compilation error. * Rename ForwardDerivativeTranscriber->ForwardDiffTranscriber. * Remove unused fields from Transcriber classes. * More small cleanups. * Cleanup. Co-authored-by: Yong He <yhe@nvidia.com>
2022-12-19Separate primal computations from unzipped function into an explicit ↵Yong He
function. (#2569) Co-authored-by: Yong He <yhe@nvidia.com>
2022-12-20s/TRACTING/TRACING/ (#2567)Ellie Hermaszewska
Closes #2561
2022-12-14Fix code generation for matrix reshape. (#2568)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2022-12-12Added support for nested calls (#2562)Sai Praveen Bangaru
* Added initial support for nested calls * removed comments Co-authored-by: Yong He <yonghe@outlook.com>
2022-12-12Refactor shader cache (#2558)skallweitNV
* Fix a bug in Path::find * Fix code formatting * Fix LockFile and add LockFileGuard * Add PersistentCache and unit test * Replace file path dependency list with source file dependency list * Add note on ordering in Module/FileDependencyList * Remove old shader cache code * Refactor shader cache implementation * Temporarily skip unit tests reading/writing files * Fix warning * Reenable lock file test * Rename shader cache tests and disable crashing test * Testing * Stop using Path::getCanonical * Fix persistent cache lock and test * Fix threading issues * Move adding file dependency hashes to getEntryPointHash() * Fix handling of #include files * Allow specifying additional search paths for gfx testing device * Work on shader cache tests * Update project files * Revive shader cache graphics tests * Split graphics pipeline test * Fix compilation
2022-12-09Add `diffPair` stdlib function. (#2560)Yong He
2022-12-08Auto-diff for matrix operations. (#2559)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2022-12-08More type support for reverse-mode (#2551)Sai Praveen Bangaru
* Add vector arithmetic test. Make gradient accumulation work for any IRLoad * Added support for general vector types, and split transposition into transpose & materialize to allow emitting the fully accumulated gradient for complex types. * Several bug fixes + finished up support for vector & struct types + removed prop pass * minor fixes (int/uint casts) * Removed IRConstruct * Added some type casts to prevent warnings * minor fix for unused variable
2022-12-07Rename IR opcodes to unify style. (#2556)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2022-12-07Remove `construct` IR op. (#2555)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>