summaryrefslogtreecommitdiff
path: root/source/slang/diff.meta.slang
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-03-28 15:19:03 -0700
committerGitHub <noreply@github.com>2023-03-28 15:19:03 -0700
commita61f089fbc4b944d058e6417d8a0d22d57ca5c92 (patch)
tree4fa1a0c6370b8d34262d297653239f48aa004c71 /source/slang/diff.meta.slang
parent8f03af5e5b580170fab3fd2fe6144f92038c7701 (diff)
Add slangpy doc, fix cuda prelude. (#2748)
* 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>
Diffstat (limited to 'source/slang/diff.meta.slang')
-rw-r--r--source/slang/diff.meta.slang44
1 files changed, 44 insertions, 0 deletions
diff --git a/source/slang/diff.meta.slang b/source/slang/diff.meta.slang
index d5dc7842a..51cf1cdb7 100644
--- a/source/slang/diff.meta.slang
+++ b/source/slang/diff.meta.slang
@@ -76,6 +76,47 @@ struct TensorView
__target_intrinsic(cuda, "$0.strides[$1]")
[__readNone]
uint stride(uint i);
+
+ __subscript(uint index) -> T
+ {
+ [ForceInline] [__readNone] get { return load(index); }
+ [ForceInline] set { store(index, newValue); }
+ }
+ __subscript(uint i1, uint i2) -> T
+ {
+ [ForceInline] [__readNone] get { return load(i1, i2); }
+ [ForceInline] set { store(i1, i2, newValue); }
+ }
+ __subscript(uint2 i) -> T
+ {
+ [ForceInline] [__readNone] get { return load(i.x, i.y); }
+ [ForceInline] set { store(i.x, i.y, newValue); }
+ }
+ __subscript(uint i1, uint i2, uint i3) -> T
+ {
+ [ForceInline] [__readNone] get { return load(i1, i2, i3); }
+ [ForceInline] set { store(i1, i2, i3, newValue); }
+ }
+ __subscript(uint3 i) -> T
+ {
+ [ForceInline] [__readNone] get { return load(i.x, i.y, i.z); }
+ [ForceInline] set { store(i.x, i.y, i.z, newValue); }
+ }
+ __subscript(uint i1, uint i2, uint i3, uint i4) -> T
+ {
+ [ForceInline] [__readNone] get { return load(i1, i2, i3, i4); }
+ [ForceInline] set { store(i1, i2, i3, i4, newValue); }
+ }
+ __subscript(uint4 i) -> T
+ {
+ [__readNone][ForceInline] get { return load(i.x, i.y, i.z, i.w); }
+ [ForceInline] set { store(i.x, i.y, i.z, i.w, newValue); }
+ }
+ __subscript(uint i1, uint i2, uint i3, uint i4, uint i5) -> T
+ {
+ [ForceInline] [__readNone] get { return load(i1, i2, i3, i4, i5); }
+ [ForceInline] set { store(i1, i2, i3, i4, i5, newValue); }
+ }
}
__generic<T>
@@ -119,6 +160,9 @@ struct TorchTensor
__intrinsic_op($(kIROp_AllocateTorchTensor))
static TorchTensor<T> alloc(uint i0, uint i1, uint i2, uint i3, uint i4);
+
+ __intrinsic_op($(kIROp_AllocateTorchTensor))
+ static TorchTensor<T> zerosLike(TorchTensor<T> other);
}
__generic<T: IDifferentiable>