tvm
|
Stage, contains scheduling for a stage of computation. More...
#include <schedule.h>
Public Types | |
using | ContainerType = StageNode |
Public Types inherited from tvm::runtime::ObjectRef | |
using | ContainerType = Object |
type indicate the container type. More... | |
Public Member Functions | |
Stage () | |
Stage (ObjectPtr< Object > n) | |
Stage (Operation op, const ScheduleNode *sch) | |
create a new schedule for op. More... | |
const StageNode * | operator-> () const |
access the internal node container More... | |
StageNode * | operator-> () |
access the internal node container More... | |
Stage & | set_scope (std::string scope) |
set the memory scope of the stage More... | |
Stage & | compute_at (Stage parent, IterVar scope) |
specify the schedule to be computed at the parent schedule's scope. More... | |
Stage & | compute_inline () |
Compute the function inline. More... | |
Stage & | compute_root () |
Compute the function at group root. More... | |
Stage & | bind (IterVar ivar, IterVar thread_ivar) |
Bind the IterVar to thread index. More... | |
Stage & | set_store_predicate (PrimExpr predicate) |
Set the predicate to determine whether a store to the array should be performed. Use this when there are multiple threads performing the same store and we only need one of them to do the store. More... | |
Stage & | env_threads (Array< IterVar > threads) |
Specify environment threads that launched around the group's scope. This can only be used in group stage. More... | |
Stage & | split (IterVar parent, PrimExpr factor, IterVar *p_outer, IterVar *p_inner, bool disable_predication=false) |
Split the parent by factor, generate. More... | |
Stage & | split_by_nparts (IterVar parent, PrimExpr nparts, IterVar *p_outer, IterVar *p_inner, bool disable_predication=false) |
Split the iteration with given number of parts. More... | |
Stage & | fuse (IterVar outer, IterVar inner, IterVar *p_target) |
Fuse the inner outer domain to the target. More... | |
Stage & | fuse (const Array< IterVar > &axes, IterVar *p_target) |
Fuse all the axes together into a single axis. More... | |
Stage & | reorder (const Array< IterVar > &order) |
Reorder the iteration. More... | |
Stage & | tile (IterVar x_parent, IterVar y_parent, PrimExpr x_factor, PrimExpr y_factor, IterVar *p_x_outer, IterVar *p_y_outer, IterVar *p_x_inner, IterVar *p_y_inner) |
Perform tiling on two dimensions The final loop order from outmost to inner most are [x_outer, y_outer, x_inner, y_inner]. More... | |
Stage & | vectorize (IterVar var) |
Vectorize iteration. More... | |
Stage & | tensorize (IterVar var, TensorIntrin f) |
Replace computation of the current stage by tensor intrinsic f. More... | |
Stage & | unroll (IterVar var) |
Unroll iteration. More... | |
Stage & | parallel (IterVar var) |
Parallelize iteration. More... | |
Stage & | pragma (IterVar var, const std::string &pragma_type, const PrimExpr &pragma_value=PrimExpr()) |
Annotate the iteration with pragma. More... | |
Stage & | prefetch (const Tensor &domain, IterVar var, PrimExpr offset) |
Fetch data in advance. More... | |
Stage & | storage_align (IterVar axis, int factor, int offset) |
Set alignment requirement for specific dimension. More... | |
Stage & | double_buffer () |
Compute current stage with double buffering. More... | |
Stage & | rolling_buffer () |
Compute current stage with rolling buffering. More... | |
Stage & | transform_layout (const Array< Var > &initial_indices, const Array< PrimExpr > &final_indices, Array< IterVar > *out_iter_vars=nullptr) |
Defines a layout transformation to be applied to the buffer. More... | |
Stage & | set_axis_separators (const Array< IntImm > &axis_separators) |
Defines separators between groups of axes. More... | |
bool | is_scheduled () const |
whether the stage has been scheduled. More... | |
Stage | GetAttachSpec () const |
Get attachment spec of current stage. If the stage compute at Group root, this function will traverse the group function to get the final spec from the group. More... | |
Public Member Functions inherited from tvm::runtime::ObjectRef | |
ObjectRef ()=default | |
default constructor More... | |
ObjectRef (ObjectPtr< Object > data) | |
Constructor from existing object ptr. More... | |
bool | same_as (const ObjectRef &other) const |
Comparator. More... | |
bool | operator== (const ObjectRef &other) const |
Comparator. More... | |
bool | operator!= (const ObjectRef &other) const |
Comparator. More... | |
bool | operator< (const ObjectRef &other) const |
Comparator. More... | |
bool | defined () const |
const Object * | get () const |
const Object * | operator-> () const |
bool | unique () const |
int | use_count () const |
template<typename ObjectType , typename = std::enable_if_t<std::is_base_of_v<Object, ObjectType>>> | |
const ObjectType * | as () const |
Try to downcast the internal Object to a raw pointer of a corresponding type. More... | |
template<typename ObjectRefType , typename = std::enable_if_t<std::is_base_of_v<ObjectRef, ObjectRefType>>> | |
Optional< ObjectRefType > | as () const |
Try to downcast the ObjectRef to a Optional<T> of the requested type. More... | |
Additional Inherited Members | |
Static Public Attributes inherited from tvm::runtime::ObjectRef | |
static constexpr bool | _type_is_nullable = true |
Protected Member Functions inherited from tvm::runtime::ObjectRef | |
Object * | get_mutable () const |
Static Protected Member Functions inherited from tvm::runtime::ObjectRef | |
template<typename T > | |
static T | DowncastNoCheck (ObjectRef ref) |
Internal helper function downcast a ref without check. More... | |
static void | FFIClearAfterMove (ObjectRef *ref) |
Clear the object ref data field without DecRef after we successfully moved the field. More... | |
template<typename ObjectType > | |
static ObjectPtr< ObjectType > | GetDataPtr (const ObjectRef &ref) |
Internal helper function get data_ as ObjectPtr of ObjectType. More... | |
Protected Attributes inherited from tvm::runtime::ObjectRef | |
ObjectPtr< Object > | data_ |
Internal pointer that backs the reference. More... | |
Stage, contains scheduling for a stage of computation.
|
inline |
|
explicit |
create a new schedule for op.
op | The operator in the schedule |
sch | The schedule which current stage belongs to |
Bind the IterVar to thread index.
ivar | The IterVar to be bound. |
thread_ivar | The thread axis to be bound. |
specify the schedule to be computed at the parent schedule's scope.
parent | The parent schedule. |
scope | The iteration point to carry the schedule. |
Stage& tvm::te::Stage::compute_inline | ( | ) |
Compute the function inline.
Stage& tvm::te::Stage::compute_root | ( | ) |
Compute the function at group root.
Stage& tvm::te::Stage::double_buffer | ( | ) |
Compute current stage with double buffering.
Specify environment threads that launched around the group's scope. This can only be used in group stage.
threads | The threads to be launched around the scope. |
Fuse all the axes together into a single axis.
axes | All the axes to be fused. |
p_target | The result target domain. |
Fuse the inner outer domain to the target.
outer | The outer domain to be fused. |
inner | The inner domain to be fused |
p_target | The result target domain. |
Stage tvm::te::Stage::GetAttachSpec | ( | ) | const |
Get attachment spec of current stage. If the stage compute at Group root, this function will traverse the group function to get the final spec from the group.
bool tvm::te::Stage::is_scheduled | ( | ) | const |
whether the stage has been scheduled.
|
inline |
access the internal node container
|
inline |
access the internal node container
Parallelize iteration.
var | The axis to be parallelized. |
Stage& tvm::te::Stage::pragma | ( | IterVar | var, |
const std::string & | pragma_type, | ||
const PrimExpr & | pragma_value = PrimExpr() |
||
) |
Annotate the iteration with pragma.
var | The axis to be parallelized. |
pragma_type | The pragma type. |
pragma_value | The pragma value |
Fetch data in advance.
domain | the tensor to be prefetched |
var | the iteration point at which to apply prefetching |
offset | the number of iterations be to fetched in advance |
Reorder the iteration.
order | The order of iteration variable. |
Stage& tvm::te::Stage::rolling_buffer | ( | ) |
Compute current stage with rolling buffering.
Defines separators between groups of axes.
Used to define BufferNode::axis_separators
, which has additional details.
axis_separators | A list of axis separators. |
Stage& tvm::te::Stage::set_scope | ( | std::string | scope | ) |
set the memory scope of the stage
scope | The memory scope. |
Set the predicate to determine whether a store to the array should be performed. Use this when there are multiple threads performing the same store and we only need one of them to do the store.
predicate | The condition to be checked. |
Stage& tvm::te::Stage::split | ( | IterVar | parent, |
PrimExpr | factor, | ||
IterVar * | p_outer, | ||
IterVar * | p_inner, | ||
bool | disable_predication = false |
||
) |
Split the parent by factor, generate.
parent | The parent iteration domain. |
factor | The split factor of the loop. |
p_outer | The result outer domain |
p_inner | The result inner domain. |
disable_predication | If enabled, don't create a predicate for guarding the loop. This can be useful when splitting with scalable factors that the schedule writer knows are divisible by the loop bound. Warning: enabling this feature may result in incorrect code generation if not used carefully. |
Stage& tvm::te::Stage::split_by_nparts | ( | IterVar | parent, |
PrimExpr | nparts, | ||
IterVar * | p_outer, | ||
IterVar * | p_inner, | ||
bool | disable_predication = false |
||
) |
Split the iteration with given number of parts.
parent | The parent domain. |
nparts | The number of parts in the outer domain. |
p_outer | The result outer domain. |
p_inner | The result inner domain. |
disable_predication | If enabled, don't create a predicate for guarding the loop. This can be useful when splitting with scalable factors that the schedule writer knows are divisible by the loop bound. Warning: enabling this feature may result in incorrect code generation if not used carefully. |
Set alignment requirement for specific dimension.
Such that stride[axis] == k * factor + offset for some k.
axis | The dimension to be specified for alignment. |
factor | The factor multiple of alignment |
offset | The required offset factor. |
Stage& tvm::te::Stage::tensorize | ( | IterVar | var, |
TensorIntrin | f | ||
) |
Replace computation of the current stage by tensor intrinsic f.
var | The axis marks beginning of tensorization. Every operations inside the axis(include axis itself is tensorized). |
f | The Tensor compute intrinsics. |
Stage& tvm::te::Stage::tile | ( | IterVar | x_parent, |
IterVar | y_parent, | ||
PrimExpr | x_factor, | ||
PrimExpr | y_factor, | ||
IterVar * | p_x_outer, | ||
IterVar * | p_y_outer, | ||
IterVar * | p_x_inner, | ||
IterVar * | p_y_inner | ||
) |
Perform tiling on two dimensions The final loop order from outmost to inner most are [x_outer, y_outer, x_inner, y_inner].
x_parent | The original x dimension |
y_parent | The original y dimension |
x_factor | The stride factor on x axis |
y_factor | The stride factor on y axis |
p_x_outer | Outer axis of x dimension |
p_y_outer | Outer axis of y dimension |
p_x_inner | Inner axis of x dimension |
p_y_inner | Inner axis of y dimension |
Stage& tvm::te::Stage::transform_layout | ( | const Array< Var > & | initial_indices, |
const Array< PrimExpr > & | final_indices, | ||
Array< IterVar > * | out_iter_vars = nullptr |
||
) |
Defines a layout transformation to be applied to the buffer.
The map from initial_index to final_index must be an invertible affine transformation.
initial_indices | An array of variables to represent a value's location in the tensor, using the pre-transformation layout. These variables are used as binding occurrences to represent the initial indices when applying the initial->final mapping, and should not occur elsewhere in the Schedule. (i.e. Pass in newly constructed variables, not the initial IterVar::var) |
final_indices | An array of expressions, giving the value's location in the tensor, using the post-transformation layout. Expressions should be in terms of the variables given in initial_indices. |
out_iter_vars | An optional output location for the updated loop iteration variables. |
Unroll iteration.
var | The axis to be unrolled. |
Vectorize iteration.
var | The axis to be vectorized. |