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/ffi/container/shape.h>
23 #include <tvm/ffi/reflection/registry.h>
24 #include <tvm/ir/module.h>
25 #include <tvm/node/node.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  TVM_FFI_DECLARE_OBJECT_INFO("meta_schedule.ArgInfo", ArgInfoNode, runtime::Object);
37 
38  public:
40  virtual ~ArgInfoNode() = default;
42  virtual ObjectRef AsJSON() const = 0;
43 };
44 
49 class ArgInfo : public runtime::ObjectRef {
50  public:
56  TVM_DLL static ArgInfo FromJSON(const ObjectRef& json_obj);
62  TVM_DLL static ffi::Array<ArgInfo, void> FromPrimFunc(const tir::PrimFunc& func);
69  TVM_DLL static ffi::Array<ArgInfo, void> FromEntryFunc(const IRModule& mod, bool remove_preproc);
70 
72 
73  protected:
74  ArgInfo() = default;
75 };
76 
78 class TensorInfoNode : public ArgInfoNode {
79  public:
83  ffi::Shape shape;
84 
85  static void RegisterReflection() {
86  namespace refl = tvm::ffi::reflection;
87  refl::ObjectDef<TensorInfoNode>()
88  .def_ro("dtype", &TensorInfoNode::dtype)
89  .def_ro("shape", &TensorInfoNode::shape);
90  }
92 
93  public:
94  ObjectRef AsJSON() const;
95 };
96 
101 class TensorInfo : public ArgInfo {
102  public:
108  TVM_DLL explicit TensorInfo(runtime::DataType dtype, ffi::Shape shape);
114  TVM_DLL static TensorInfo FromJSON(const ObjectRef& json_obj);
116 };
117 
118 } // namespace meta_schedule
119 } // namespace tvm
120 
121 #endif // TVM_META_SCHEDULE_ARG_INFO_H_
Managed reference class to IRModuleNode.
Definition: module.h:256
The argument information.
Definition: arg_info.h:34
TVM_FFI_DECLARE_OBJECT_INFO("meta_schedule.ArgInfo", ArgInfoNode, runtime::Object)
virtual ObjectRef AsJSON() const =0
Converts the ArgInfo to its corresponding JSON representation.
virtual ~ArgInfoNode()=default
Default destructor.
Managed reference to ArgInfoNode.
Definition: arg_info.h:49
static ffi::Array< ArgInfo, void > FromPrimFunc(const tir::PrimFunc &func)
Extract a list of the argument information from PrimFunc.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ArgInfo, runtime::ObjectRef, ArgInfoNode)
static ffi::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 ArgInfo FromJSON(const ObjectRef &json_obj)
Parse the argument information from a JSON object.
The tensor argument information.
Definition: arg_info.h:78
ffi::Shape shape
The shape of the tensor.
Definition: arg_info.h:83
runtime::DataType dtype
The data type of the tensor.
Definition: arg_info.h:81
ObjectRef AsJSON() const
Converts the ArgInfo to its corresponding JSON representation.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("meta_schedule.TensorInfo", TensorInfoNode, ArgInfoNode)
static void RegisterReflection()
Definition: arg_info.h:85
Managed reference to TensorInfoNode.
Definition: arg_info.h:101
static TensorInfo FromJSON(const ObjectRef &json_obj)
Parse the argument information from a JSON object.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(TensorInfo, ArgInfo, TensorInfoNode)
TensorInfo(runtime::DataType dtype, ffi::Shape shape)
Constructor of TensorInfo.
Runtime primitive data type.
Definition: data_type.h:47
Managed reference to PrimFuncNode.
Definition: function.h:129
IRModule that holds the functions and type definitions.
Definition: repr_printer.h:91
tvm::PrimExpr mod(const tvm::PrimExpr &a, const tvm::PrimExpr &b)
Definition: broadcast.h:308
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:1960
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:37
Definitions and helper macros for IR/AST nodes.
A managed object in the TVM runtime.
TIR Function.