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_S_TIR_META_SCHEDULE_ARG_INFO_H_
20 #define TVM_S_TIR_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/runtime/data_type.h>
26 #include <tvm/tirx/function.h>
27 
28 namespace tvm {
29 namespace s_tir {
30 namespace meta_schedule {
31 
33 class ArgInfoNode : public ffi::Object {
34  public:
35  TVM_FFI_DECLARE_OBJECT_INFO("s_tir.meta_schedule.ArgInfo", ArgInfoNode, ffi::Object);
36 
37  public:
39  virtual ~ArgInfoNode() = default;
41  virtual ffi::ObjectRef AsJSON() const = 0;
42 };
43 
48 class ArgInfo : public ffi::ObjectRef {
49  public:
55  TVM_DLL static ArgInfo FromJSON(const ffi::ObjectRef& json_obj);
61  TVM_DLL static ffi::Array<ArgInfo, void> FromPrimFunc(const tirx::PrimFunc& func);
68  TVM_DLL static ffi::Array<ArgInfo, void> FromEntryFunc(const IRModule& mod, bool remove_preproc);
69 
71 
72  protected:
73  ArgInfo() = default;
74 };
75 
77 class TensorInfoNode : public ArgInfoNode {
78  public:
82  ffi::Shape shape;
83 
84  static void RegisterReflection() {
85  namespace refl = tvm::ffi::reflection;
86  refl::ObjectDef<TensorInfoNode>()
87  .def_ro("dtype", &TensorInfoNode::dtype)
88  .def_ro("shape", &TensorInfoNode::shape);
89  }
90  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("s_tir.meta_schedule.TensorInfo", TensorInfoNode, ArgInfoNode);
91 
92  public:
93  ffi::ObjectRef AsJSON() const;
94 };
95 
100 class TensorInfo : public ArgInfo {
101  public:
107  TVM_DLL explicit TensorInfo(runtime::DataType dtype, ffi::Shape shape);
113  TVM_DLL static TensorInfo FromJSON(const ffi::ObjectRef& json_obj);
115 };
116 
117 } // namespace meta_schedule
118 } // namespace s_tir
119 } // namespace tvm
120 
121 #endif // TVM_S_TIR_META_SCHEDULE_ARG_INFO_H_
Managed reference class to IRModuleNode.
Definition: module.h:258
Runtime primitive data type.
Definition: data_type.h:45
The argument information.
Definition: arg_info.h:33
TVM_FFI_DECLARE_OBJECT_INFO("s_tir.meta_schedule.ArgInfo", ArgInfoNode, ffi::Object)
virtual ~ArgInfoNode()=default
Default destructor.
virtual ffi::ObjectRef AsJSON() const =0
Converts the ArgInfo to its corresponding JSON representation.
Managed reference to ArgInfoNode.
Definition: arg_info.h:48
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ArgInfo, ffi::ObjectRef, ArgInfoNode)
static ffi::Array< ArgInfo, void > FromPrimFunc(const tirx::PrimFunc &func)
Extract a list of the argument information from PrimFunc.
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 ffi::ObjectRef &json_obj)
Parse the argument information from a JSON object.
The tensor argument information.
Definition: arg_info.h:77
static void RegisterReflection()
Definition: arg_info.h:84
runtime::DataType dtype
The data type of the tensor.
Definition: arg_info.h:80
ffi::ObjectRef AsJSON() const
Converts the ArgInfo to its corresponding JSON representation.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("s_tir.meta_schedule.TensorInfo", TensorInfoNode, ArgInfoNode)
ffi::Shape shape
The shape of the tensor.
Definition: arg_info.h:82
Managed reference to TensorInfoNode.
Definition: arg_info.h:100
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(TensorInfo, ArgInfo, TensorInfoNode)
TensorInfo(runtime::DataType dtype, ffi::Shape shape)
Constructor of TensorInfo.
static TensorInfo FromJSON(const ffi::ObjectRef &json_obj)
Parse the argument information from a JSON object.
Managed reference to PrimFuncNode.
Definition: function.h:131
IRModule that holds the functions and type definitions.
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:1981
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition: analyzer.h:37
TIR Function.