Safe Haskell | None |
---|---|
Language | GHC2024 |
HordeAd.Core.AstInterpret
Description
Interpretation of AST terms in an arbitrary tensor operations class instance. With the exception of the the interpretation of the sharing mechanisms and any other performance tweaks, the interpretation is the unique homorphism determined by the instance. The sharing mechanisms are translated so as to preserve sharing in case the instance is a term algebra as well.
Synopsis
- interpretAstFull :: forall target (y :: TK). ADReady target => AstEnv target -> AstTensor 'AstMethodLet 'FullSpan y -> target y
- interpretAstPrimal :: forall (target :: Target) (y :: TK). ADReady target => AstEnv target -> AstTensor 'AstMethodLet 'PrimalSpan y -> PrimalOf target y
- interpretAstDual :: forall (target :: Target) (y :: TK). ADReady target => AstEnv target -> AstTensor 'AstMethodLet 'DualSpan y -> DualOf target y
- interpretAst :: forall target (s :: AstSpanType) (y :: TK). (ADReady target, AstSpan s) => AstEnv target -> AstTensor 'AstMethodLet s y -> target y
- interpretAstBool :: forall (target :: Target). ADReady target => AstEnv target -> AstBool 'AstMethodLet -> BoolOf target
Documentation
interpretAstFull :: forall target (y :: TK). ADReady target => AstEnv target -> AstTensor 'AstMethodLet 'FullSpan y -> target y Source #
interpretAstPrimal :: forall (target :: Target) (y :: TK). ADReady target => AstEnv target -> AstTensor 'AstMethodLet 'PrimalSpan y -> PrimalOf target y Source #
interpretAstDual :: forall (target :: Target) (y :: TK). ADReady target => AstEnv target -> AstTensor 'AstMethodLet 'DualSpan y -> DualOf target y Source #
interpretAst :: forall target (s :: AstSpanType) (y :: TK). (ADReady target, AstSpan s) => AstEnv target -> AstTensor 'AstMethodLet s y -> target y Source #
Interpret a term in an environment.
Note that for PrimalSpan
term, the results of this function
land in target y
and not in PrimalOf target y
.
To make it sound nevertheless, we maintain an invariant that a value
of interpretation of a term with PrimalSpan
has zero dual part
and of a term with DualSpan
has zero primal part.
The invariants holds by the properties of instances of Ops
(see especially the ADVal instance, which zeroes dual part of many ops)
and structural induction on Ast, inspecting spans of constructors.
This promotion from PrimalOf target y
to target y
coincides
with how most operations that in Ast have PrimalSpan
,
don't have PrimalOf
(but have full target instead)
in their method signatures in Ops
, for user convenience.
See, e.g., AstConcreteS
vs tsconcrete
and AstFloorS
vs tsfloor
.
Exported only to specialize elsewhere
interpretAstBool :: forall (target :: Target). ADReady target => AstEnv target -> AstBool 'AstMethodLet -> BoolOf target Source #