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 
122  void VisitAttrs(AttrVisitor* v);
123 
130 
134  Optional<Target> FindPrimitiveTargetForKind(const std::string& kind_name) const;
135 
148  VirtualDevice CanonicalVirtualDevice(const VirtualDevice& virtual_device) const;
149 
150  static constexpr const char* _type_key = "CompilationConfig";
152 
153  private:
163  void Init(const transform::PassContext& pass_ctx, const Array<Target>& raw_targets);
164 
168  static Target MakeDefaultCPUTarget();
169 
173  mutable VirtualDeviceCache virtual_device_cache_;
174 
175  friend class CompilationConfig;
176 };
177 
183 class CompilationConfig : public ObjectRef {
184  public:
189  TVM_DLL CompilationConfig(const transform::PassContext& pass_ctx,
190  const Array<Target>& raw_targets);
191 
193 };
194 
195 } // namespace tvm
196 
197 #endif // TVM_TARGET_COMPILATION_CONFIG_H_
friend class CompilationConfig
Definition: compilation_config.h:175
Managed reference class to CompilationConfig.
Definition: compilation_config.h:183
constexpr const char * device_type
The device type.
Definition: stmt.h:1357
A compile time representation for where data is to be stored at runtime, and how to compile code to c...
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
static VirtualDevice FullyUnconstrained()
Returns the unique fully unconstrained VirtualDevice.
Optional< Target > FindPrimitiveTargetForKind(const std::string &kind_name) const
Returns the unique Target to use for kind_name. Returns null if none such.
A cache of VirtualDevices. This can be used:
Definition: virtual_device.h:349
base class of all object containers.
Definition: object.h:167
static constexpr const char * _type_key
Definition: compilation_config.h:150
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 VirtualDeviceNode.
Definition: virtual_device.h:261
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:270
Target optional_homogeneous_target
If defined then compile and/or run in &#39;homogenous execution mode&#39;. In this mode all primitives are co...
Definition: compilation_config.h:120
Target host_target
The host target. Used for &#39;scalar&#39; data and code (such as shapes and shape functions) and residual Re...
Definition: compilation_config.h:65
PassContext that is used to configure the pass behavior.
Definition: transform.h:154
#define TVM_DEFINE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:713
Managed reference class to TargetNode.
Definition: target.h:141
Base class of all object reference.
Definition: object.h:511
VirtualDevice default_primitive_virtual_device
VirtualDevice for primitive operators which are not otherwise constrained to a particular device...
Definition: compilation_config.h:106
#define TVM_DECLARE_FINAL_OBJECT_INFO(TypeName, ParentType)
helper macro to declare type information in a final class.
Definition: object.h:671
void VisitAttrs(AttrVisitor *v)
VirtualDevice host_virtual_device
VirtualDevice for the host.
Definition: compilation_config.h:109
Optional container that to represent to a Nullable variant of T.
Definition: optional.h:51
VirtualDevice CanonicalVirtualDevice(const VirtualDevice &virtual_device) const
Returns a VirtualDevice agreeing with virtual_device on all its constrained fields, however:
Array< Target > primitive_targets
Vector of all available Targets for partitioning or compiling primitive tensor operators (kernels)...
Definition: compilation_config.h:99
Gathers the Targets and distinguished VirtualDevices in canonical form needed to compile a Relay modu...
Definition: compilation_config.h:54
Target FindPrimitiveTargetForDeviceOrFail(DLDeviceType device_type) const
Returns the unique Target to use for device_type. Fail if no such target exists.