tvm
arg_info.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_ARG_INFO_H_
20 #define TVM_META_SCHEDULE_ARG_INFO_H_
21 
22 #include <tvm/ir/module.h>
23 #include <tvm/node/node.h>
24 #include <tvm/node/reflection.h>
26 #include <tvm/runtime/data_type.h>
27 #include <tvm/runtime/object.h>
28 #include <tvm/tir/function.h>
29 
30 namespace tvm {
31 namespace meta_schedule {
32 
34 class ArgInfoNode : public runtime::Object {
35  public:
36  static constexpr const char* _type_key = "meta_schedule.ArgInfo";
38 
39  public:
41  virtual ~ArgInfoNode() = default;
43  virtual ObjectRef AsJSON() const = 0;
44 };
45 
50 class ArgInfo : public runtime::ObjectRef {
51  public:
57  TVM_DLL static ArgInfo FromJSON(const ObjectRef& json_obj);
63  TVM_DLL static Array<ArgInfo, void> FromPrimFunc(const tir::PrimFunc& func);
70  TVM_DLL static Array<ArgInfo, void> FromEntryFunc(const IRModule& mod, bool remove_preproc);
71 
73 
74  protected:
75  ArgInfo() = default;
76 };
77 
79 class TensorInfoNode : public ArgInfoNode {
80  public:
85 
87  v->Visit("dtype", &dtype);
88  v->Visit("shape", &shape);
89  }
90 
91  static constexpr const char* _type_key = "meta_schedule.TensorInfo";
93 
94  public:
95  ObjectRef AsJSON() const;
96 };
97 
102 class TensorInfo : public ArgInfo {
103  public:
115  TVM_DLL static TensorInfo FromJSON(const ObjectRef& json_obj);
117 };
118 
119 } // namespace meta_schedule
120 } // namespace tvm
121 
122 #endif // TVM_META_SCHEDULE_ARG_INFO_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 IRModuleNode.
Definition: module.h:366
The argument information.
Definition: arg_info.h:34
virtual ObjectRef AsJSON() const =0
Converts the ArgInfo to its corresponding JSON representation.
static constexpr const char * _type_key
Definition: arg_info.h:36
TVM_DECLARE_BASE_OBJECT_INFO(ArgInfoNode, runtime::Object)
virtual ~ArgInfoNode()=default
Default destructor.
Managed reference to ArgInfoNode.
Definition: arg_info.h:50
static Array< ArgInfo, void > FromEntryFunc(const IRModule &mod, bool remove_preproc)
Extract a list of the argument information from the entry func of an IRModule.
static Array< ArgInfo, void > FromPrimFunc(const tir::PrimFunc &func)
Extract a list of the argument information from PrimFunc.
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(ArgInfo, runtime::ObjectRef, ArgInfoNode)
static ArgInfo FromJSON(const ObjectRef &json_obj)
Parse the argument information from a JSON object.
The tensor argument information.
Definition: arg_info.h:79
TVM_DECLARE_FINAL_OBJECT_INFO(TensorInfoNode, ArgInfoNode)
runtime::DataType dtype
The data type of the tensor.
Definition: arg_info.h:82
ObjectRef AsJSON() const
Converts the ArgInfo to its corresponding JSON representation.
void VisitAttrs(tvm::AttrVisitor *v)
Definition: arg_info.h:86
static constexpr const char * _type_key
Definition: arg_info.h:91
runtime::ShapeTuple shape
The shape of the tensor.
Definition: arg_info.h:84
Managed reference to TensorInfoNode.
Definition: arg_info.h:102
static TensorInfo FromJSON(const ObjectRef &json_obj)
Parse the argument information from a JSON object.
TensorInfo(runtime::DataType dtype, runtime::ShapeTuple shape)
Constructor of TensorInfo.
TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(TensorInfo, ArgInfo, TensorInfoNode)
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
Runtime primitive data type.
Definition: data_type.h:43
Base class of all object reference.
Definition: object.h:519
base class of all object containers.
Definition: object.h:171
Reference to shape tuple objects.
Definition: shape_tuple.h:85
Managed reference to PrimFuncNode.
Definition: function.h:145
IRModule that holds the functions and type definitions.
tvm::PrimExpr mod(const tvm::PrimExpr &a, const tvm::PrimExpr &b)
Definition: broadcast.h:290
Tensor shape(const Tensor &src, DataType dtype, const std::string name="T_shape", const std::string tag=kInjective)
Get the shape of input tensor.
Definition: transform.h:1913
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
Definitions and helper macros for IR/AST nodes.
A managed object in the TVM runtime.
Reflection and serialization of compiler IR/AST nodes.
Runtime ShapeTuple container types.
TIR Function.