Instruction¶
-
class Instruction¶
Base class for a compute-graph operation.
Each instruction has a name, an integer opcode and a differentiable flag, and derives its output types from its input types through
signature. The concrete subclasses are an internal implementation detail. User code adds instructions through the generated FunctionBuilder methods.Subclassed by madspace::AcceptNormInstruction, madspace::BatchCatInstruction, madspace::BatchGatherInstruction, madspace::BatchMergeByIndexInstruction, madspace::BatchScatterInstruction, madspace::BatchSizeInstruction, madspace::BatchSplitByIndexInstruction, madspace::BatchSplitInstruction, madspace::CatInstruction, madspace::FullInstruction, madspace::MatrixElementInstruction, madspace::NonzeroInstruction, madspace::OffsetIndicesInstruction, madspace::RandomInstruction, madspace::RandomIntInstruction, madspace::RqsReshapeInstruction, madspace::SimpleInstruction, madspace::SqueezeInstruction, madspace::StackInstruction, madspace::StackSizesInstruction, madspace::UnsqueezeInstruction, madspace::UnstackInstruction, madspace::UnstackSizesInstruction, madspace::UnweightInstruction
Public Functions
-
inline Instruction(const std::string &name, int opcode, bool differentiable)¶
- Parameters:
name – instruction name, matching
instruction_set.yamlopcode – integer opcode used by the runtime dispatch
differentiable – whether the runtime can backpropagate through it
-
virtual ~Instruction() = default¶
-
virtual TypeVec signature(const ValueVec &args) const = 0¶
Output types produced for the given argument values.
-
inline const std::string &name() const¶
Instruction name, matching
instruction_set.yaml.
-
inline int opcode() const¶
Integer opcode used by the runtime dispatch.
-
inline bool differentiable() const¶
Whether the runtime can backpropagate through this instruction.
-
inline virtual bool is_random() const¶
Whether the instruction draws from a shared RNG stream.
Such an instruction is never deduplicated and is always scheduled on the main GPU stream; see FunctionBuilder::instruction.
-
inline Instruction(const std::string &name, int opcode, bool differentiable)¶