Defined in File operator_node.h
public mgb::cg::GraphExecutable (Class GraphExecutable)
Node for an operator.
An operator is defined to be a node that could generate one or more VarNode as output.
Each operator node must be purely functional, i.e. the same node evaluated on the same input value must produce the same output value
Each operator has an owner, the computing graph that it belongs to
used by add_input() to sort vars for deduplication
sort newly added vars
sort all currently added vars
hash that combines all inputs, m_config.comp_node() and all add_equivalence_component calls
get node prop, which is available and constant after node construction
Note that this function calls do_make_node_prop() on first call
called by ComputingGraph to mark that this node has been inserted in graph; inputs and outputs could not be later changed
Execute the operator by starting all kernels on device.
wait on input as indicated by get_input_waiting_spec
allocate memory for dynamic outputs
set_ready on output
get computing nodes that need to wait on other vars
This is only valid after the computing func has been compiled.
set input waiting spec
This should only be called from SeqCompNodeOptimizerImpl::init_ready_event() or EagerEvalManager
add layout constraint for input vars by calling VarNode::add_layout_constraint
Note that this method is always called exactly once for operators that are inserted into the computing sequence
called by graph compiler to setup readonly memory forwarding
This function would always be called unless input has dynamic storage but output has static storage
called by graph compiler to setup writable memory forwarding
get callbacks to be invoked on events related to this operator; default implementation returns empty event
called when stream of comp node of output vars is changed for graph optimization
initialize output dtype by calling VarNode::dtype
The default implementation requires all inputs to have the same dtype and set output dtype to it
This function is called once during operator insertion.
initialize output format by calling VarNode::format
The default implementation require all inputs to have the same non-default format and set all non-volatile outputs format to it.
This function is called once during operator insertion
inititialize output comp_node by calling VarNode::comp_node
call VarNode::add_rt_force_dynamic_mem_alloc_imply_chain on input and output vars
register static infer descriptors for output vars by calling methods on ComputingGraph::static_infer_manager()
initialize mem alloc plan for output nodes
Mem plans are used for memory optimization; the storage of var node’s device tensor should always come from mem plan
Default implmentation works by calling VarNode::init_mem_plan on vars that match dynamic param
output(…)->shape() is guaranteed to be valid before calling this function.
Remember to add Flag::IMPURE_OUTPUT_MEM_PLAN if needed.
dynamic: if true, initialize mem plans for vars that could not be statically inferred; otherwise for statically inferable vars
add input var to this operator
allocate a new output VarNode; the name would be appended to this->name to form the final name
add extra component for equivalence check
This is only a helper function to make the default hash() and is_same() implementation consider other components in addition to all the input nodes; you can also override hash() and is_same() to implement deduplication.
Note that the order for calling add_equivalence_component matters. Also note that all input vars are used for deduplication by default.
allocate a new node prop and initialize dep entry as all inputs
Update operator priority.
This method would be invoked if and only if initializing m_node_prop or after the graph optimizer modified the opr’s priority.
whether the priority would be changed.
input_var_naming: used for generating default node name
actually execute; all input and output have been checked, and the subclasses only need to perform the actual computing
pack of params in constructor, to ease inheritance
specifies waiting strategy on one comp node for input vars
on which comp node to wait other inputs
vars that must be ready on device
struct to specify the callback function pointers for various operator events.
This exists mainly for optimization: if a callback is not needed, related surronding code would not be inserted into execution queue.
called when memory status changed
Memory status is defined by all layouts and addresses of DEV_VALUE deps and outputs; if any of it changes, this callback would be called before execution