tvm
Loading...
Searching...
No Matches
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/dtype.h>
24#include <tvm/ffi/reflection/registry.h>
25#include <tvm/ir/module.h>
26#include <tvm/ir/prim/expr.h>
27#include <tvm/tirx/function.h>
28
29namespace tvm {
30namespace s_tir {
31namespace meta_schedule {
32
34class ArgInfoObj : public ffi::Object {
35 public:
36 TVM_FFI_DECLARE_OBJECT_INFO("s_tir.meta_schedule.ArgInfo", ArgInfoObj, ffi::Object);
37
38 public:
40 virtual ~ArgInfoObj() = default;
42 virtual ffi::ObjectRef AsJSON() const = 0;
43};
44
49class ArgInfo : public ffi::ObjectRef {
50 public:
56 TVM_DLL static ArgInfo FromJSON(const ffi::ObjectRef& json_obj);
62 TVM_DLL static ffi::Array<ArgInfo, void> FromFunction(const tirx::Function& 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
78class TensorInfoObj : public ArgInfoObj {
79 public:
81 DLDataType dtype;
83 ffi::Shape shape;
84
85 static void RegisterReflection() {
86 namespace refl = tvm::ffi::reflection;
87 refl::ObjectDef<TensorInfoObj>()
88 .def_ro("dtype", &TensorInfoObj::dtype)
89 .def_ro("shape", &TensorInfoObj::shape);
90 }
91 TVM_FFI_DECLARE_OBJECT_INFO_FINAL("s_tir.meta_schedule.TensorInfo", TensorInfoObj, ArgInfoObj);
92
93 public:
94 ffi::ObjectRef AsJSON() const;
95};
96
101class TensorInfo : public ArgInfo {
102 public:
108 TVM_DLL explicit TensorInfo(DLDataType dtype, ffi::Shape shape);
114 TVM_DLL static TensorInfo FromJSON(const ffi::ObjectRef& json_obj);
116};
117
118} // namespace meta_schedule
119} // namespace s_tir
120} // namespace tvm
121
122#endif // TVM_S_TIR_META_SCHEDULE_ARG_INFO_H_
Managed reference class to IRModuleNode.
Definition module.h:255
The argument information.
Definition arg_info.h:34
TVM_FFI_DECLARE_OBJECT_INFO("s_tir.meta_schedule.ArgInfo", ArgInfoObj, ffi::Object)
virtual ~ArgInfoObj()=default
Default destructor.
virtual ffi::ObjectRef AsJSON() const =0
Converts the ArgInfo to its corresponding JSON representation.
Managed reference to ArgInfoObj.
Definition arg_info.h:49
static ffi::Array< ArgInfo, void > FromFunction(const tirx::Function &func)
Extract a list of the argument information from Function.
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.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ArgInfo, ffi::ObjectRef, ArgInfoObj)
The tensor argument information.
Definition arg_info.h:78
ffi::Shape shape
The shape of the tensor.
Definition arg_info.h:83
static void RegisterReflection()
Definition arg_info.h:85
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("s_tir.meta_schedule.TensorInfo", TensorInfoObj, ArgInfoObj)
DLDataType dtype
The data type of the tensor.
Definition arg_info.h:81
ffi::ObjectRef AsJSON() const
Converts the ArgInfo to its corresponding JSON representation.
Managed reference to TensorInfoObj.
Definition arg_info.h:101
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(TensorInfo, ArgInfo, TensorInfoObj)
TensorInfo(DLDataType 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 FunctionNode.
Definition function.h:105
TIR expressions.
IRModule that holds the functions and type definitions.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition attr.h:23
TIR Function.