Class

scalan.primitives.UniversalOps

OpCost

Related Doc: package UniversalOps

Permalink

case class OpCost(lambdaVar: Scalan.Sym, costedValueId: Int, args: Seq[Scalan.Ref[Int]], opCost: Scalan.Ref[Int]) extends Scalan.BaseDef[Int] with Product with Serializable

Special graph node to represent accumulation of the operation costs. In general, due to node sharing it is incorrect to just sum up all the args costs and add resCost to that value. Example:
val x = .. val y = op1(x) val z = op2(x) val res = op3(y, z) The naive summation will lead to the cost of x is accumulated both into cost of y and into cost of z, so in the cost of res it is accumulated twice. To avoid this problem OpCost nodes require special handling in during evaluation.

lambdaVar

the variable of the lambda in which scope this node is created. This makes this node belong to the lambda body, even if it doesn't otherwise depend on lambda argument.

costedValueId

The id of the node for which this node represents cost

args

costs of the arguments, which are here represent dependency information.

opCost

operation cost, which should be added to the current scope accumulated cost

Linear Supertypes
Serializable, Serializable, Scalan.BaseDef[Int], Scalan.Def[Int], Scalan.Node, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. OpCost
  2. Serializable
  3. Serializable
  4. BaseDef
  5. Def
  6. Node
  7. Product
  8. Equals
  9. AnyRef
  10. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new OpCost(lambdaVar: Scalan.Sym, costedValueId: Int, args: Seq[Scalan.Ref[Int]], opCost: Scalan.Ref[Int])

    Permalink

    lambdaVar

    the variable of the lambda in which scope this node is created. This makes this node belong to the lambda body, even if it doesn't otherwise depend on lambda argument.

    costedValueId

    The id of the node for which this node represents cost

    args

    costs of the arguments, which are here represent dependency information.

    opCost

    operation cost, which should be added to the current scope accumulated cost

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. val args: Seq[Scalan.Ref[Int]]

    Permalink

    costs of the arguments, which are here represent dependency information.

  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. val costedValueId: Int

    Permalink

    The id of the node for which this node represents cost

  8. final def deps: Array[Scalan.Sym]

    Permalink

    Dependencies of this definition from other definitions.

    Dependencies of this definition from other definitions. If definition is interpreted as an operation, then dependencies are arguments of the operation. If definition if compound (like Lambda of ThunkDef) then deps is equals to free variables used in the body of the compound definition. This array also refers to predecessors of this graph node, so it is used to build topological ordering (execution schedule) of operations.

    returns

    array of referencies to other definitions.

    Definition Classes
    Node
  9. final def elements: Array[AnyRef]

    Permalink

    All data elements of this graph node to be used in structural equality.

    All data elements of this graph node to be used in structural equality.

    Definition Classes
    Node
    See also

    equals where elements are used.

  10. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  11. def equals(other: Any): Boolean

    Permalink

    Default equality of definitions.

    Default equality of definitions. Two definitions are equal if they have same elements.

    Definition Classes
    Node → Equals → AnyRef → Any
  12. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  14. def getDeps: Array[Scalan.Sym]

    Permalink

    Override to redefine how dependencies are computed.

    Override to redefine how dependencies are computed. For example, in core implementation this is overriden in Lambda and ThunkDef using freeVars.

    Attributes
    protected
    Definition Classes
    Node
  15. def hashCode(): Int

    Permalink

    Computed once and saved to avoid repeated computations, which is not necessary because definitions are immutable by default.

    Computed once and saved to avoid repeated computations, which is not necessary because definitions are immutable by default. If some definition require mutability, this method can be overriden accordingly.

    Definition Classes
    Node → AnyRef → Any
  16. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  17. val lambdaVar: Scalan.Sym

    Permalink

    the variable of the lambda in which scope this node is created.

    the variable of the lambda in which scope this node is created. This makes this node belong to the lambda body, even if it doesn't otherwise depend on lambda argument.

  18. def mirror(t: Scalan.Transformer): Scalan.Ref[Int]

    Permalink

    Clone this definition transforming all symbols using t.

    Clone this definition transforming all symbols using t. If new Def[A] is created, it is added to the graph with collapsing and rewriting. Can be overriden to implement node-specific mirroring (see MethodCall).

    t

    mapping of symbols to symbols (Ref[_] => Ref[_])

    returns

    symbol of the logical clone. If d don't contain symbols, then d.self is returned.

    Definition Classes
    Def
  19. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  20. final def nodeId: Int

    Permalink

    Unique id of the graph node assigned for each new instance using freshId generator.

    Unique id of the graph node assigned for each new instance using freshId generator. Doesn't participate in equality of this Def, thus definitions with different ids may still be structurally equal. Used to provide global Def numbering.

    Definition Classes
    Node
    Annotations
    @inline()
  21. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  22. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  23. val opCost: Scalan.Ref[Int]

    Permalink

    operation cost, which should be added to the current scope accumulated cost

  24. implicit val resultType: Scalan.Elem[Int]

    Permalink

    Type of a resulting value produced by the operation represented by this definition.

    Type of a resulting value produced by the operation represented by this definition. For example, if this definition represents application of +: (Int, Int) => Int operation then the result type is Int and resultType should return IntElement.

    Definition Classes
    BaseDefDef
  25. final def self: Scalan.Ref[Int]

    Permalink

    Reference to this definition created lazily on demand.

    Reference to this definition created lazily on demand.

    Definition Classes
    Def
  26. final def syms: Array[Scalan.Sym]

    Permalink

    References to other nodes in this Def instance.

    References to other nodes in this Def instance. Note: This is different form deps for compound definitions like Lambda and ThunkDef.

    Definition Classes
    Node
  27. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  28. def toString(): String

    Permalink

    User readable string representation of this definition.

    User readable string representation of this definition. (for debugging only)

    Definition Classes
    Node → AnyRef → Any
  29. def transform(t: Scalan.Transformer): Scalan.OpCost

    Permalink

    When this node is mirrored (as part of mirrorLambda) we apply transformer t for all arguments with standard data flow semantics.

    When this node is mirrored (as part of mirrorLambda) we apply transformer t for all arguments with standard data flow semantics. However this is not correct to do for lambdaVar. Instead we use current lambda from the top of the stack, which is always points to the most nested lambda.

    Definition Classes
    OpCostDef
  30. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from Scalan.BaseDef[Int]

Inherited from Scalan.Def[Int]

Inherited from Scalan.Node

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped