tvm
search_task.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 
25 #ifndef TVM_AUTO_SCHEDULER_SEARCH_TASK_H_
26 #define TVM_AUTO_SCHEDULER_SEARCH_TASK_H_
27 
29 #include <tvm/runtime/ndarray.h>
30 #include <tvm/target/target.h>
31 
32 namespace tvm {
33 namespace auto_scheduler {
34 
35 class HardwareParams;
36 
38 class HardwareParamsNode : public Object {
39  public:
41  int num_cores;
46 
47  // GPU related parameters got from device query API
57  int warp_size;
58 
60  v->Visit("num_cores", &num_cores);
61  v->Visit("vector_unit_bytes", &vector_unit_bytes);
62  v->Visit("cache_line_bytes", &cache_line_bytes);
63  v->Visit("max_shared_memory_per_block", &max_shared_memory_per_block);
64  v->Visit("max_local_memory_per_block", &max_local_memory_per_block);
65  v->Visit("max_threads_per_block", &max_threads_per_block);
66  v->Visit("max_vthread_extent", &max_vthread_extent);
67  v->Visit("warp_size", &warp_size);
68  }
69 
76  static HardwareParams GetDefaultHardwareParams(const Target& target, const Target& target_host);
77 
78  static constexpr const char* _type_key = "auto_scheduler.HardwareParams";
80 };
81 
86 class HardwareParams : public ObjectRef {
87  public:
99  HardwareParams(int num_cores, int vector_unit_bytes, int cache_line_bytes,
100  int max_shared_memory_per_block, int max_local_memory_per_block,
101  int max_threads_per_block, int max_vthread_extent, int warp_size);
102 
105 };
106 
110 class SearchTaskNode : public Object {
111  public:
128 
130  v->Visit("compute_dag", &compute_dag);
131  v->Visit("workload_key", &workload_key);
132  v->Visit("desc", &desc);
133  v->Visit("target", &target);
134  v->Visit("target_host", &target_host);
135  v->Visit("hardware_params", &hardware_params);
136  v->Visit("layout_rewrite_option", &layout_rewrite_option);
137  v->Visit("task_input_names", &task_input_names);
138  }
139 
140  static constexpr const char* _type_key = "auto_scheduler.SearchTask";
142 };
143 
148 class SearchTask : public ObjectRef {
149  public:
161  SearchTask(ComputeDAG compute_dag, String workload_key, Target target, Target target_host,
162  Optional<HardwareParams> hardware_params, LayoutRewriteOption layout_rewrite_option,
163  Array<String> task_input_names, String desc = "");
164 
166 };
167 
168 } // namespace auto_scheduler
169 } // namespace tvm
170 
171 #endif // TVM_AUTO_SCHEDULER_SEARCH_TASK_H_
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
Managed reference class to TargetNode.
Definition: target.h:200
Managed reference to ComputeDAGNode.
Definition: compute_dag.h:219
The parameters of target hardware used to guide the SearchPolicy.
Definition: search_task.h:38
int max_local_memory_per_block
The max local memory per block in bytes.
Definition: search_task.h:51
static HardwareParams GetDefaultHardwareParams(const Target &target, const Target &target_host)
Get the default hardware params.
int cache_line_bytes
The size of cache line in bytes.
Definition: search_task.h:45
int max_threads_per_block
The max number of threads per block.
Definition: search_task.h:53
int max_vthread_extent
The max vthread extent.
Definition: search_task.h:55
int max_shared_memory_per_block
The max shared memory per block in bytes.
Definition: search_task.h:49
TVM_DECLARE_FINAL_OBJECT_INFO(HardwareParamsNode, Object)
int vector_unit_bytes
The width of vector units in bytes.
Definition: search_task.h:43
int num_cores
The number of cores.
Definition: search_task.h:41
int warp_size
The thread numbers of a warp.
Definition: search_task.h:57
void VisitAttrs(tvm::AttrVisitor *v)
Definition: search_task.h:59
static constexpr const char * _type_key
Definition: search_task.h:78
Managed reference to HardwareParamsNode.
Definition: search_task.h:86
HardwareParams(int num_cores, int vector_unit_bytes, int cache_line_bytes, int max_shared_memory_per_block, int max_local_memory_per_block, int max_threads_per_block, int max_vthread_extent, int warp_size)
The constructor.
TVM_DEFINE_OBJECT_REF_METHODS(HardwareParams, ObjectRef, HardwareParamsNode)
TVM_DEFINE_OBJECT_REF_COW_METHOD(HardwareParamsNode)
The computation information and hardware parameters for a specific schedule search task.
Definition: search_task.h:110
static constexpr const char * _type_key
Definition: search_task.h:140
String workload_key
The workload key for the compute declaration.
Definition: search_task.h:115
String desc
The description string of this task.
Definition: search_task.h:117
ComputeDAG compute_dag
The ComputeDAG for the compute declaration.
Definition: search_task.h:113
TVM_DECLARE_FINAL_OBJECT_INFO(SearchTaskNode, Object)
HardwareParams hardware_params
Hardware parameters used in this search task.
Definition: search_task.h:123
Array< String > task_input_names
Names of some user defined input data used in program measuring.
Definition: search_task.h:127
Target target
The target device of this search task.
Definition: search_task.h:119
LayoutRewriteOption layout_rewrite_option
The layout rewrite option used for measuring programs.
Definition: search_task.h:125
void VisitAttrs(tvm::AttrVisitor *v)
Definition: search_task.h:129
Target target_host
The target host device of this search task.
Definition: search_task.h:121
Managed reference to SearchTaskNode.
Definition: search_task.h:148
TVM_DEFINE_OBJECT_REF_METHODS(SearchTask, ObjectRef, SearchTaskNode)
SearchTask(ComputeDAG compute_dag, String workload_key, Target target, Target target_host, Optional< HardwareParams > hardware_params, LayoutRewriteOption layout_rewrite_option, Array< String > task_input_names, String desc="")
The constructor.
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
Base class of all object reference.
Definition: object.h:519
base class of all object containers.
Definition: object.h:171
Optional container that to represent to a Nullable variant of T.
Definition: optional.h:51
Reference to string objects.
Definition: string.h:98
The auto-scheduler's computational graph and related program analyses.
LayoutRewriteOption
Options for applying layout rewrite. This is an optimization to rewrite the layout of input tensors a...
Definition: compute_dag.h:201
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
A device-independent managed NDArray abstraction.
Compilation target object.