8000 make tensor type representation internal by dsyme · Pull Request #176 · DiffSharp/DiffSharp · GitHub
[go: up one dir, main page]

Skip to content

make tensor type representation internal #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 20, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
make tensor type representation internal
  • Loading branch information
dsyme committed Sep 9, 2020
commit 8d80b8d9cc4eaae809ff912bc7ff7d1e1f5e93d6
5 changes: 3 additions & 2 deletions src/DiffSharp.Core/Tensor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type scalar = IConvertible

[<CustomEquality; CustomComparison>]
type Tensor =
internal
| Tensor of primalRaw:RawTensor
| TensorF of primal:Tensor * derivative:Tensor * nestingTag:uint32
| TensorR of primal:Tensor * derivative:(Tensor ref) * parentOp:TensorOp * fanout:(uint32 ref) * nestingTag:uint32
Expand Down Expand Up @@ -455,13 +456,13 @@ type Tensor =

static member inline (-->) (t:Tensor, f:Tensor -> ^a) = f t

static member inline OpUnary(a, fRaw, fTensor, dfTensorFwd, dfTensorRev) =
static member inline internal OpUnary(a, fRaw, fTensor, dfTensorFwd, dfTensorRev) =
match a with
| Tensor(ap) -> Tensor(fRaw(ap))
| TensorF(ap,ad,at) -> let cp = fTensor(ap) in TensorF(cp, dfTensorFwd(cp,ap,ad), at)
| TensorR(ap,_,_,_,at) -> let cp = fTensor(ap) in TensorR(cp, ref (a.zeroLike()), dfTensorRev(a), ref 0u, at)

static member inline OpBinary(a, b, fRaw, fTensor, dfTensorFwdTT, dfTensorFwdTC, dfTensorFwdCT, dfTensorRevTT, dfTensorRevTC, dfTensorRevCT) =
static member inline internal OpBinary(a, b, fRaw, fTensor, dfTensorFwdTT, dfTensorFwdTC, dfTensorFwdCT, dfTensorRevTT, dfTensorRevTC, dfTensorRevCT) =
match a, b with
| Tensor(ap), Tensor(bp) -> Tensor(fRaw(ap, bp))
| Tensor(_), TensorF(bp,bd,bt) -> let cp = fTensor(a,bp) in TensorF(cp, dfTensorFwdCT(cp,bp,bd), bt)
Expand Down
0