tvm
Public Member Functions | Static Public Attributes | List of all members
tvm::auto_scheduler::ComputeDAG Class Reference

Managed reference to ComputeDAGNode. More...

#include <compute_dag.h>

Inheritance diagram for tvm::auto_scheduler::ComputeDAG:
Collaboration diagram for tvm::auto_scheduler::ComputeDAG:

Public Member Functions

 ComputeDAG (Array< te::Tensor > tensors)
 Construct a DAG from a list of output tensors. More...
 
 ComputeDAG (const te::Schedule &sch)
 Construct a DAG based on a schedule. More...
 
ComputeDAG RewriteLayout (Array< Step > *transform_steps, LayoutRewriteOption layout_rewrite) const
 Rewrite the layout of placeholder specified by attr layout_free_placeholders according to the loop nest derived with transform_steps. More...
 
std::pair< te::Schedule, Array< te::Tensor > > ApplySteps (const Array< Step > &transform_steps, Array< te::Stage > *stages=nullptr, StageToAxesMap *stage_to_axes=nullptr, LayoutRewriteOption layout_rewrite=LayoutRewriteOption::NoRewrite) const
 Apply the history transform steps to get a TVM schedule. More...
 
String PrintStepsAsPython (const Array< Step > &transform_steps) const
 Print transform steps as equivalent python schedule API. This can be used for debugging. More...
 
String PrintDAG (bool simple_mode=false) const
 Print the compute DAG to a string. This is also used to generate the ComputeDAG hash. More...
 
State InferBound (const State &state) const
 Fill the correct bound information for a given state by calling ir_pass::InferBound. The states can lose complete bound information after some transform steps (e.g., compute_at). We can call this function to infer and fill all the bound information. This function calls TVM InferBound pass internally to get the bound. The returned state of this function is guaranteed to have complete bound information. More...
 
Array< StateInferBound (const Array< State > &states) const
 Fill the correct bound information for the given states by calling ir_pass::InferBound. The states can lose complete bound information after some transform steps (e.g., compute_at). We can call this function to infer and fill all the bound information. This function calls TVM InferBound pass internally to get the bound. The returned state of this function is guaranteed to have complete bound information. More...
 
ComputeDAG ReplayAndGetDAG (const Array< Step > &steps) const
 Since some steps may change the ComputeDAG (e.g. CacheRead/CacheWrite), the initial ComputeDAG may not be up-to-date. This function replays the given transform steps from the initial state and returns an up-to-date ComputeDAG. More...
 
 TVM_DEFINE_OBJECT_REF_METHODS (ComputeDAG, ObjectRef, ComputeDAGNode)
 
 TVM_DEFINE_OBJECT_REF_COW_METHOD (ComputeDAGNode)
 
- 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 Objectget () const
 
const Objectoperator-> () 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...
 

Static Public Attributes

static constexpr const char * layout_free_placeholders_key = "layout_free_placeholders"
 
- Static Public Attributes inherited from tvm::runtime::ObjectRef
static constexpr bool _type_is_nullable = true
 

Additional Inherited Members

- Public Types inherited from tvm::runtime::ObjectRef
using ContainerType = Object
 type indicate the container type. More...
 
- Protected Member Functions inherited from tvm::runtime::ObjectRef
Objectget_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< Objectdata_
 Internal pointer that backs the reference. More...
 

Detailed Description

Managed reference to ComputeDAGNode.

See also
ComputeDAGNode

Constructor & Destructor Documentation

◆ ComputeDAG() [1/2]

tvm::auto_scheduler::ComputeDAG::ComputeDAG ( Array< te::Tensor tensors)
explicit

Construct a DAG from a list of output tensors.

Parameters
tensorste::Tensors for a compute declaration.

◆ ComputeDAG() [2/2]

tvm::auto_scheduler::ComputeDAG::ComputeDAG ( const te::Schedule sch)
explicit

Construct a DAG based on a schedule.

Parameters
schte::Schedules for a compute declaration.

Member Function Documentation

◆ ApplySteps()

std::pair<te::Schedule, Array<te::Tensor> > tvm::auto_scheduler::ComputeDAG::ApplySteps ( const Array< Step > &  transform_steps,
Array< te::Stage > *  stages = nullptr,
StageToAxesMap stage_to_axes = nullptr,
LayoutRewriteOption  layout_rewrite = LayoutRewriteOption::NoRewrite 
) const

Apply the history transform steps to get a TVM schedule.

Parameters
transform_stepsTransform steps of a state.
stagesThe list of stages after applying the steps. Pass a valid pointer if this information needs to be used outside this function.
stage_to_axesThe map that stores all axes for one stage. Pass a valid pointer if this information needs to be used outside this function.
layout_rewriteRewrite the layout of placeholders specified by attr layout_free_placeholders.
Returns
A te.schedule and the an Array of te.Tensor to be used in tvm.lower or tvm.build.

◆ InferBound() [1/2]

Array<State> tvm::auto_scheduler::ComputeDAG::InferBound ( const Array< State > &  states) const

Fill the correct bound information for the given states by calling ir_pass::InferBound. The states can lose complete bound information after some transform steps (e.g., compute_at). We can call this function to infer and fill all the bound information. This function calls TVM InferBound pass internally to get the bound. The returned state of this function is guaranteed to have complete bound information.

Parameters
statesThe input states.
Returns
The States with complete bound information.
Note
The returned array will contains empty State, if there're infer bound failure on some states.

◆ InferBound() [2/2]

State tvm::auto_scheduler::ComputeDAG::InferBound ( const State state) const

Fill the correct bound information for a given state by calling ir_pass::InferBound. The states can lose complete bound information after some transform steps (e.g., compute_at). We can call this function to infer and fill all the bound information. This function calls TVM InferBound pass internally to get the bound. The returned state of this function is guaranteed to have complete bound information.

Parameters
stateThe input state.
Returns
The State with complete bound information

◆ PrintDAG()

String tvm::auto_scheduler::ComputeDAG::PrintDAG ( bool  simple_mode = false) const

Print the compute DAG to a string. This is also used to generate the ComputeDAG hash.

Parameters
simple_modeSimple mode will only include the op names and brief compute.
Returns
The ComputeDAG in a string.

◆ PrintStepsAsPython()

String tvm::auto_scheduler::ComputeDAG::PrintStepsAsPython ( const Array< Step > &  transform_steps) const

Print transform steps as equivalent python schedule API. This can be used for debugging.

Parameters
transform_stepsTransform steps of a state.
Returns
The Python schedule code.

◆ ReplayAndGetDAG()

ComputeDAG tvm::auto_scheduler::ComputeDAG::ReplayAndGetDAG ( const Array< Step > &  steps) const

Since some steps may change the ComputeDAG (e.g. CacheRead/CacheWrite), the initial ComputeDAG may not be up-to-date. This function replays the given transform steps from the initial state and returns an up-to-date ComputeDAG.

Parameters
stepsThe steps to be replayed. Usually we'll filter out the unused steps to speed up the replay process, since we only intend to get a ComputeDAG with the up-to-date op stage structure.
Returns
The up-to-date ComputeDAG.

◆ RewriteLayout()

ComputeDAG tvm::auto_scheduler::ComputeDAG::RewriteLayout ( Array< Step > *  transform_steps,
LayoutRewriteOption  layout_rewrite 
) const

Rewrite the layout of placeholder specified by attr layout_free_placeholders according to the loop nest derived with transform_steps.

Parameters
transform_stepsTransform steps of a state.
layout_rewriteDifferent options in layout rewrite.
Returns
The updated ComputeDAG after layout rewrite.

◆ TVM_DEFINE_OBJECT_REF_COW_METHOD()

tvm::auto_scheduler::ComputeDAG::TVM_DEFINE_OBJECT_REF_COW_METHOD ( ComputeDAGNode  )

◆ TVM_DEFINE_OBJECT_REF_METHODS()

tvm::auto_scheduler::ComputeDAG::TVM_DEFINE_OBJECT_REF_METHODS ( ComputeDAG  ,
ObjectRef  ,
ComputeDAGNode   
)

Member Data Documentation

◆ layout_free_placeholders_key

constexpr const char* tvm::auto_scheduler::ComputeDAG::layout_free_placeholders_key = "layout_free_placeholders"
staticconstexpr

The documentation for this class was generated from the following file: