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/node/node.h>
24 #include <tvm/tir/function.h>
25 
26 namespace tvm {
27 namespace meta_schedule {
28 
30 class ArgInfoNode : public runtime::Object {
31  public:
32  static constexpr const char* _type_key = "meta_schedule.ArgInfo";
34 
35  public:
37  virtual ~ArgInfoNode() = default;
39  virtual ObjectRef AsJSON() const = 0;
40 };
41 
46 class ArgInfo : public runtime::ObjectRef {
47  public:
53  TVM_DLL static ArgInfo FromJSON(const ObjectRef& json_obj);
59  TVM_DLL static Array<ArgInfo, void> FromPrimFunc(const tir::PrimFunc& func);
60 
62 
63  protected:
64  ArgInfo() = default;
65 };
66 
68 class TensorInfoNode : public ArgInfoNode {
69  public:
74 
76  v->Visit("dtype", &dtype);
77  v->Visit("shape", &shape);
78  }
79 
80  static constexpr const char* _type_key = "meta_schedule.TensorInfo";
82 
83  public:
84  ObjectRef AsJSON() const;
85 };
86 
91 class TensorInfo : public ArgInfo {
92  public:
98  TVM_DLL explicit TensorInfo(runtime::DataType dtype, runtime::ShapeTuple shape);
104  TVM_DLL static TensorInfo FromJSON(const ObjectRef& json_obj);
106 };
107 
108 } // namespace meta_schedule
109 } // namespace tvm
110 
111 #endif // TVM_META_SCHEDULE_ARG_INFO_H_
#define TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:751
Definitions and helper macros for IR/AST nodes.
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:36
virtual ~ArgInfoNode()=default
Default destructor.
TIR Function.
base class of all object containers.
Definition: object.h:165
virtual ObjectRef AsJSON() const =0
Converts the ArgInfo to its corresponding JSON representation.
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
Runtime primitive data type.
Definition: data_type.h:41
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:270
Managed reference to PrimFuncNode.
Definition: function.h:135
Managed reference to TensorInfoNode.
Definition: arg_info.h:91
The tensor argument information.
Definition: arg_info.h:68
void VisitAttrs(tvm::AttrVisitor *v)
Definition: arg_info.h:75
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:1608
Base class of all object reference.
Definition: object.h:504
runtime::DataType dtype
The data type of the tensor.
Definition: arg_info.h:71
Runtime ShapeTuple container types.
#define TVM_DECLARE_FINAL_OBJECT_INFO(TypeName, ParentType)
helper macro to declare type information in a final class.
Definition: object.h:664
The argument information.
Definition: arg_info.h:30
TVM_DECLARE_BASE_OBJECT_INFO(ArgInfoNode, runtime::Object)
Managed reference to ArgInfoNode.
Definition: arg_info.h:46
static constexpr const char * _type_key
Definition: arg_info.h:32
#define TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:721
runtime::ShapeTuple shape
The shape of the tensor.
Definition: arg_info.h:73
Reference to shape tuple objects.
Definition: shape_tuple.h:81