tvm
compilation_config.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_TARGET_COMPILATION_CONFIG_H_
26 #define TVM_TARGET_COMPILATION_CONFIG_H_
27 
29 
30 #include <string>
31 
32 namespace tvm {
33 
54 class CompilationConfigNode : public Object {
55  public:
66 
100 
107 
110 
121 
123 
130 
134  Optional<Target> FindPrimitiveTargetForKind(const std::string& kind_name) const;
135 
140  Target CanonicalTarget(const Target& target) const;
141 
156  VirtualDevice CanonicalVirtualDevice(const VirtualDevice& virtual_device) const;
157 
158  static constexpr const char* _type_key = "CompilationConfig";
160 
161  private:
171  void Init(const transform::PassContext& pass_ctx, const Array<Target>& raw_targets);
172 
176  static Target MakeDefaultCPUTarget();
177 
181  mutable VirtualDeviceCache virtual_device_cache_;
182 
183  friend class CompilationConfig;
184 };
185 
191 class CompilationConfig : public ObjectRef {
192  public:
197  TVM_DLL CompilationConfig(const transform::PassContext& pass_ctx,
198  const Array<Target>& raw_targets);
199 
201 };
202 
203 } // namespace tvm
204 
205 #endif // TVM_TARGET_COMPILATION_CONFIG_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
Gathers the Targets and distinguished VirtualDevices in canonical form needed to compile a Relay modu...
Definition: compilation_config.h:54
void VisitAttrs(AttrVisitor *v)
VirtualDevice host_virtual_device
VirtualDevice for the host.
Definition: compilation_config.h:109
Target CanonicalTarget(const Target &target) const
Returns a Target structurally equal to target, however prefer a structually equal known host or primi...
VirtualDevice CanonicalVirtualDevice(const VirtualDevice &virtual_device) const
Returns a VirtualDevice which is structurally equal to virtual_device on all its constrained fields,...
static constexpr const char * _type_key
Definition: compilation_config.h:158
Target host_target
The host target. Used for 'scalar' data and code (such as shapes and shape functions) and residual Re...
Definition: compilation_config.h:65
Array< Target > primitive_targets
Vector of all available Targets for partitioning or compiling primitive tensor operators (kernels)....
Definition: compilation_config.h:99
Target FindPrimitiveTargetForDeviceOrFail(DLDeviceType device_type) const
Returns the unique Target to use for device_type. Fail if no such target exists.
VirtualDevice default_primitive_virtual_device
VirtualDevice for primitive operators which are not otherwise constrained to a particular device....
Definition: compilation_config.h:106
Target optional_homogeneous_target
If defined then compile and/or run in 'homogenous execution mode'. In this mode all primitives are co...
Definition: compilation_config.h:120
Optional< Target > FindPrimitiveTargetForKind(const std::string &kind_name) const
Returns the unique Target to use for kind_name. Returns null if none such.
Managed reference class to CompilationConfig.
Definition: compilation_config.h:191
TVM_DEFINE_OBJECT_REF_METHODS(CompilationConfig, ObjectRef, CompilationConfigNode)
CompilationConfig(const transform::PassContext &pass_ctx, const Array< Target > &raw_targets)
Constructs the compilation config given the settings in pass_ctx and supplied raw_targets....
Managed reference class to TargetNode.
Definition: target.h:200
A cache of VirtualDevices. This can be used:
Definition: virtual_device.h:358
Managed reference class to VirtualDeviceNode.
Definition: virtual_device.h:271
static VirtualDevice FullyUnconstrained()
Returns the unique fully unconstrained VirtualDevice.
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
PassContext that is used to configure the pass behavior.
Definition: transform.h:182
constexpr const char * device_type
The device type.
Definition: stmt.h:1422
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
#define TVM_DECLARE_FINAL_OBJECT_INFO(TypeName, ParentType)
helper macro to declare type information in a final class.
Definition: object.h:702
A compile time representation for where data is to be stored at runtime, and how to compile code to c...