Class

cogx.compiler.cpu_operator

Operator

Related Doc: package cpu_operator

Permalink

abstract class Operator extends SemanticError

A user-defined operator, allowing the user to write Cog code that can't be easily parallelized and must be executed on the CPU.

To define an Operator, create an object which extends this class and define a 'compute' method in it. Here's an example:

/** An operator which flips a picture upside down. */
object upsideDown extends Operator {
  def compute(in: ScalarFieldReader, out: ScalarFieldWriter) {
    out.setShape(in.fieldShape)
    for (row <- 0 until in.rows; col <- 0 until in.columns) {
      val pixel = in.read(row, col)
      result.write(in.rows - row - 1, col, pixel)
    }
  }
}

To invoke this operator, use it like a function:

val graph = new ComputeGraph {
   val field = ScalarField(...)
   val flipped = upsideDown(field)
}

This class does the necessary reflective magic to connect up the compute method, which is written using *FieldReader and *FieldWriter objects, to Fields.

Linear Supertypes
SemanticError, CompilerError, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Operator
  2. SemanticError
  3. CompilerError
  4. AnyRef
  5. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Operator()

    Permalink

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 Verbose: Boolean

    Permalink

    Debugging flag.

  5. def apply(inputs: parser.syntaxtree.Field*): parser.syntaxtree.Field

    Permalink

    Create an instance of the operator.

    Create an instance of the operator.

    inputs

    Fields that are inputs to the operator.

    returns

    Field resulting from execution of the operator.

  6. final def asInstanceOf[T0]: T0

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit

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

    Permalink
    Definition Classes
    AnyRef → Any
  12. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  13. def internalError(message: String): Unit

    Permalink

    Declare an internal error described by message.

    Declare an internal error described by message.

    Definition Classes
    CompilerError
  14. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  15. val name: String

    Permalink

    User-defined name of the operator.

  16. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  17. final def notify(): Unit

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

    Permalink
    Definition Classes
    AnyRef
  19. final def synchronized[T0](arg0: ⇒ T0): T0

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

    Permalink
    Definition Classes
    AnyRef → Any
  21. final def wait(): Unit

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

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

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

Inherited from SemanticError

Inherited from CompilerError

Inherited from AnyRef

Inherited from Any

Ungrouped