tvm
space_generator.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 #ifndef TVM_META_SCHEDULE_SPACE_GENERATOR_H_
20 #define TVM_META_SCHEDULE_SPACE_GENERATOR_H_
21 
22 #include <tvm/ir/module.h>
23 #include <tvm/node/reflection.h>
25 #include <tvm/runtime/object.h>
28 
29 namespace tvm {
30 namespace meta_schedule {
31 
32 // Forward declaration
33 class TuneContext;
34 
72  public:
74  virtual ~SpaceGeneratorNode() = default;
75 
81  virtual void InitializeWithTuneContext(const TuneContext& context) = 0;
82 
89 
90  static constexpr const char* _type_key = "meta_schedule.SpaceGenerator";
92 };
93 
96  public:
108 
113 
115  // `f_initialize_with_tune_context` is not visited
116  // `f_generate_design_space` is not visited
117  }
118 
119  void InitializeWithTuneContext(const TuneContext& context) final;
121 
122  static constexpr const char* _type_key = "meta_schedule.PySpaceGenerator";
124 };
125 
131  protected:
132  SpaceGenerator() = default;
133 
134  public:
141  TVM_DLL static SpaceGenerator PySpaceGenerator(
142  PySpaceGeneratorNode::FInitializeWithTuneContext f_initialize_with_tune_context,
143  PySpaceGeneratorNode::FGenerateDesignSpace f_generate_design_space);
144 
150  TVM_DLL static SpaceGenerator SpaceGeneratorUnion(Array<SpaceGenerator, void> space_generators);
156  TVM_DLL static SpaceGenerator PostOrderApply();
158 };
159 
160 } // namespace meta_schedule
161 } // namespace tvm
162 
163 #endif // TVM_META_SCHEDULE_SPACE_GENERATOR_H_
virtual ~SpaceGeneratorNode()=default
Default destructor.
TVM_DECLARE_BASE_OBJECT_INFO(SpaceGeneratorNode, Object)
#define TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:758
IRModule that holds the functions and type definitions.
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
The design space generator with customized methods on the python-side.
Definition: space_generator.h:95
base class of all object containers.
Definition: object.h:167
Managed reference to TuneContextNode.
Definition: tune_context.h:129
Runtime Array container types.
Visitor class to get the attributes of an AST/IR node. The content is going to be called for each fie...
Definition: reflection.h:52
virtual Array< tir::Schedule > GenerateDesignSpace(const IRModule &mod)=0
Generate design spaces given a module.
The abstract class for design space generation.
Definition: space_generator.h:71
virtual void InitializeWithTuneContext(const TuneContext &context)=0
Initialize the design space generator with tuning context.
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:270
Base class of all object reference.
Definition: object.h:511
void VisitAttrs(tvm::AttrVisitor *v)
Definition: space_generator.h:114
A managed object in the TVM runtime.
#define TVM_DECLARE_FINAL_OBJECT_INFO(TypeName, ParentType)
helper macro to declare type information in a final class.
Definition: object.h:671
Managed reference class to IRModuleNode.
Definition: module.h:360
FInitializeWithTuneContext f_initialize_with_tune_context
The packed function to the InitializeWithTuneContext function.
Definition: space_generator.h:110
tvm::PrimExpr mod(const tvm::PrimExpr &a, const tvm::PrimExpr &b)
Definition: broadcast.h:290
Reflection and serialization of compiler IR/AST nodes.
FGenerateDesignSpace f_generate_design_space
The packed function to the GenerateDesignSpace function.
Definition: space_generator.h:112
static constexpr const char * _type_key
Definition: space_generator.h:90
Type-erased function used across TVM API.
Managed reference to SpaceGeneratorNode.
Definition: space_generator.h:130