| Age | Commit message (Collapse) | Author |
|
|
|
* Make sure `NullDifferential` and its witness are removed after autodiff.
* Fix.
* Add a test.
|
|
|
|
Addresses #4698 as one approach to diagnose the potential problem.
Emit warnings when a user marks a parameter as `inout` but never writes to it in the function. A new intrinsic function `unmodified(out T)` has been added to explicitly indicate that an `inout` variable will not be modified in the function.
This is only one way to address the specific validation error in #4698. In general it seems that DXC does some more extensive checks on actual struct fields (as opposed to observing arbitrary struct writes), so that will be the next step.
|
|
* Remove use of `G0` and `__target_intrinsic` in stdlib.
* Fix.
* Fix calling intrinsic in global scope.
|
|
* Replace __target_intrinsics and __specialize_for_target
Partially resolves #3906
Most but not all __target_intrinsics are replaced with __target_switch.
All __specialize_for_target are replaced with __target_switch.
This change is mostly processed by a temporary c++ program mechanically.
Because the change is already too big, the remaining __target_intrinsics
will be replaced later in another commit.
* Fix indentations
* Add diff.meta.slang
* Revert the change in __sizeOf<>().
"$G0" doesn't seem to work. It needs to be addressed later.
* Revert more functions that use `$G0` keyword
|
|
* Fix a bug in fwd-diff for cross product
* Also add a test for the reverse-mode AD
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
|
|
|
* Implement basic GLSL built-in functions
Partially resolves #3362
This change implemented GLSL build-in functions described in the
following sections of "OpenGL Spec" document.
8.1. Angle and Trigonometry Functions
8.2. Exponential Functions
8.3. Common Functions
8.5. Geometric Functions
8.7. Vector Relational Functions
8.8. Integer Functions
About 40 functions are newly implemented and about 150 functions
were preexisted on HLSL side implementation.
The implementation of new functions hasn't been tested yet.
* Unify some of GLSL functions into hlsl.meta.slang
Partially resoves #3362
This change moves Some of GLSL functions from glsl.meta.slang to
hlsl.meta.slang, because those functions are generic enough to be used
for HLSL. Those functions are: dot, normalize, fma, and reflect.
There was "fma" for double in hlsl.meta.slang and it is converted to use
__BuiltinFloatingPointType type, which required some modifications in
diff.meta.slang. The implementation for "fma" in diff.meta.slang is very
similar to how "mad" is implemented.
* Implement more GLSL built-in functions
Partially resolves #3362
This change implements more GLSL built-in functions mentioned in the
following sections.
8.4. Floating-Point Pack and Unpack Functions
8.6. Matrix Functions
This change implemented 11 new GLSL built-in functions and there were 3
already working functions.
The mistake in "normalize" is fixed.
"refract" function is moved from glsl.meta.slang to hlsl.meta.slang.
* Implement basic GLSL built-in functions
Partially resolves #3362
This change implemented GLSL build-in functions described in the
following sections of "OpenGL Spec" document.
8.1. Angle and Trigonometry Functions
8.2. Exponential Functions
8.3. Common Functions
8.5. Geometric Functions
8.7. Vector Relational Functions
8.8. Integer Functions
About 40 functions are newly implemented and about 150 functions
were preexisted on HLSL side implementation.
The implementation of new functions hasn't been tested yet.
* Unify some of GLSL functions into hlsl.meta.slang
Partially resoves #3362
This change moves Some of GLSL functions from glsl.meta.slang to
hlsl.meta.slang, because those functions are generic enough to be used
for HLSL. Those functions are: dot, normalize, fma, and reflect.
There was "fma" for double in hlsl.meta.slang and it is converted to use
__BuiltinFloatingPointType type, which required some modifications in
diff.meta.slang. The implementation for "fma" in diff.meta.slang is very
similar to how "mad" is implemented.
* Implement more GLSL built-in functions
Partially resolves #3362
This change implements more GLSL built-in functions mentioned in the
following sections.
8.4. Floating-Point Pack and Unpack Functions
8.6. Matrix Functions
This change implemented 11 new GLSL built-in functions and there were 3
already working functions.
The mistake in "normalize" is fixed.
"refract" function is moved from glsl.meta.slang to hlsl.meta.slang.
* Fix a few minor bugs on GLSL builtin functions
Partially resovles #3362
Following bugs were addressed:
1. "bitCounts" had to have a "Capability" on its function declaration.
2. "roundEven" is implemented. It is almost same to "round()" but the
behaivor is slightly different the given value is 1.5, 3.5, 5.5 and
so on.
3. umulExtended and imulExtended are simplified.
4. exp2 is implemented with "__target_switch" for GLSL and SPIR-V.
5. "tests/glsl-intrinsic/intrinsic-basic.slang" checks the results
from the GLSL functions. Currently it is mainly to test if the
functions exist or not, but it can now also test for a simple case
where the input value is zero and the result is most of the time
zero or one.
* Disable GLSL exp2 double type tests
This change disables some of GLSL exp2 related tests as a workaround.
The spir-v needs to handle the double-type argument for exp2 properly.
* Fix exp2(double) problem for SPIR-V
SPIR-V can handle a double-type input for exp2 with this change.
However, the slang-test is will failing to test it with an error message
saying, "abort compilation:".
With a simpler test case, I verified that SPIR-V assembly code is
properly generated for exp2(double) and I am not sure why slang-test is
still failing. We will need to revisit this issue later.
The simple testing is done with a following line:
outputBuffer.result[0] = float(exp2(double(outputBuffer.result[0])));
And it generated following lines and it looks correct:
; Function main
%main = OpFunction %void None %3
%5 = OpLabel
%16 = OpAccessChain %_ptr_Uniform_float %outputBuffer_0 %int_0 %uint_0
%17 = OpLoad %float %16
%19 = OpFConvert %double %17
%20 = OpFConvert %float %19
%21 = OpExtInst %float %1 Exp2 %20
%22 = OpAccessChain %_ptr_Uniform_float %outputBuffer_0 %int_0 %uint_0
OpStore %22 %21
OpReturn
OpFunctionEnd
* Add __floatCast that is safer than slang_noop_cast
Adding __floatCast that can be used for exp2 function.
|
|
* Support visibility control and default to `internal`.
* Fix wip.
* Fixes.
* Fix.
* Fix test.
* Add legacy language detection and compatibility for existing code.
* Add doc.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
|
|
|
|
Co-authored-by: Yong He <yonghe@outlook.com>
|
|
* Update user-guide with new slangpy features
* More polishing of new slangpy docs
* Update a1-02-slangpy.md
* Only require contiguity for vector element types
* Added `loadOnce/storeOnce` and subscript operations
* Added docs, `DiffTensorView.dims()` & `DiffTensorView.stride(uint)`
* Add constructors, remove storeOnce/loadOnce test
* Adjusted intrinsic definitions
|
|
* Fix atan2 stdlib derivative. Add tests for atan2
* Create dstdlib-atan2.slang.expected.txt
* Update tests
|
|
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
|
|
* Merge
* WIP: Complete auto-diff logic for existential types
* Revert "Add compiler option for generating representative hash"
This reverts commit 13b09ef4621e73844c96d64d9c111a8ed0d45aae.
* More fixes for fwd-mode AD on existential types
* Add anyValueSize inference pass
* Fix checking of `Differential.Differential==Differential`
* In-progress: infer any-value-size for existential types
* Existentials now work in forward-mode
* Overhaul handling of existential AD types. Fwd-mode works, reverse-mode requires front-end changes
* Reverse-mode now works on existentials
* Cleanup
* Remove diff rules for create existential object for now
* Revert treat-as-differentiable changes
* Fixes
* More fixes
* Cleanup
* more cleanup
* signed/unsigned
* Revert "Cleanup"
This reverts commit e4f7d71f07bb207736f90708961eeecd09a1b652.
* Cleanup (again)
* Remove public/export/keep-alive on null differential after AD pass
* Minor fix
* Update dictionary accessors
* Keep export decoration
* More fixes + Support for `kIROp_PackAnyValue`
* Merge upstream
* Update expected-failure.txt
|
|
* Support per field matrix layout
* Fix warnings.
* Fix.
* Fix tests.
* Fix spiv gen.
* Fix.
* More test fixes.
* Fix.
* Run only GPU tests on self-hosted servers.
* Remove -use-glsl-matrix-layout-modifier.
* Fix.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
|
|
* Refactor `dmul(This, Differential)` to `dmul<T:Real>(T, Differential)`
- Add AST synthesis support for generic containers
- Refactor relevant tests
* Merge dmul synthesis with dadd and dzero, and disambiguate using an enum
* Fix trailing spaces
|
|
* Various fixes for autodiff and slangpy.
* Fix cuda code gen for `select`.
* Fix getBuildTagString().
* Fix.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
|
|
|
|
code. (#2866)
* Bugfixes for warped-area reparameterization
* Update slang-ir-autodiff-transpose.h
* Update slang-ir-autodiff-transpose.h
* Mark all stdlib methods backward differentiable
* Update diff.meta.slang
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
|
* Embed stdlib documentation to AST.
* Extract documentation for attributes.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
|
|
|
|
* Cleaner impl of unary stdlib derivative functions.
* fixup
* Fix.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
|
|
Co-authored-by: Yong He <yhe@nvidia.com>
|
|
Co-authored-by: Yong He <yhe@nvidia.com>
|
|
* Add slangpy doc, fix cuda prelude.
* more bug fix.
* fix.
* fix.
* More fix.
* fix.
* f
* fix prelude.
* update prelude.
* update doc
* Update prelude.
* add zeros_like
* update doc.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
|
|
* Small fixes and cleanups on CUDA/CPP codegen.
* Disable `legalizeEmptyTypes` for now.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
|
|
* Add PyTorch C++ binding generation.
* fix
---------
Co-authored-by: Yong He <yhe@nvidia.com>
|
|
* Added higher-order differentiability decorators for built-ins + preliminary tests
* Update diff.meta.slang
|
|
* Bug fixes.
* Fix.
* Only perform autodiff for functions whose derivative is actually used.
* Fix loop optimize bug.
* Fix high order diff.
* Fix trivial diff func generation.
* Fixes.
* Cleanup.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
|
|
* Fix Phi simplification bug.
* Fix up.
* Fix.
* Fix.
* Fix.
* Fix.
* Fix.
* Fix test.
* Fix test.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
|
|
* Support high order diff pattern: `bwd_diff(fwd_diff(f))`.
* Fix.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
|
|
* Add support for `[PrimalSubstitute]` and `[PrimalSubstituteOf]`.
* Fix
* Fix.
* Cleanup.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
|
|
`[*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>
|
|
* Implement derivatives for HLSL intrinsics.
* Vector intrinsics.
* Add all intrinsics.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
|
|
(#2681)
|
|
* 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>
|
|
|
|
* 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>
|
|
* 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>
|
|
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>
|
|
|
|
* Frontend work for `[BackwardDerivative]` and `[BackwardDerivativeOf]`.
* Fix clang issue.
* Fix.
* fix gcc issue
* fix formatting.
Co-authored-by: Yong He <yhe@nvidia.com>
|
|
|
|
Co-authored-by: Yong He <yhe@nvidia.com>
|
|
|
|
|
|
|
|
* Initial plumbing of backward autodiff in the frontend.
* More plumbing.
* Initial reverse autodiff working.
* Bug fixes.
* Misc.
* Remove redundant code.
* More clean up.
* Misc.
* Rebase and add backward diff test.
* Disable test.
* Clean up.
* Minor fix.
Co-authored-by: Yong He <yhe@nvidia.com>
|