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/base.h>
23#include <tvm/ffi/container/shape.h>
24#include <tvm/ffi/dtype.h>
25#include <tvm/ffi/reflection/registry.h>
26#include <tvm/ir/module.h>
27#include <tvm/ir/prim/expr.h>
28#include <tvm/tirx/function.h>
29
30namespace tvm {
31namespace s_tir {
32namespace meta_schedule {
33
35class ArgInfoObj : public ffi::Object {
36 public:
37 TVM_FFI_DECLARE_OBJECT_INFO("s_tir.meta_schedule.ArgInfo", ArgInfoObj, ffi::Object);
38
39 public:
41 virtual ~ArgInfoObj() = default;
43 virtual ffi::ObjectRef AsJSON() const = 0;
44};
45
50class ArgInfo : public ffi::ObjectRef {
51 public:
57 TVM_DLL static ArgInfo FromJSON(const ffi::ObjectRef& json_obj);
63 TVM_DLL static ffi::Array<ArgInfo, void> FromFunction(const tirx::Function& func);
70 TVM_DLL static ffi::Array<ArgInfo, void> FromEntryFunc(const IRModule& mod, bool remove_preproc);
71
73
74 protected:
75 ArgInfo() = default;
76};
77
79class TensorInfoObj : public ArgInfoObj {
80 public:
82 DLDataType dtype;
84 ffi::Shape shape;
85
86 static void RegisterReflection() {
87 namespace refl = tvm::ffi::reflection;
88 refl::ObjectDef<TensorInfoObj>()
89 .def_ro("dtype", &TensorInfoObj::dtype)
90 .def_ro("shape", &TensorInfoObj::shape);
91 }
92 TVM_FFI_DECLARE_OBJECT_INFO_FINAL("s_tir.meta_schedule.TensorInfo", TensorInfoObj, ArgInfoObj);
93
94 public:
95 ffi::ObjectRef AsJSON() const;
96};
97
102class TensorInfo : public ArgInfo {
103 public:
109 TVM_DLL explicit TensorInfo(DLDataType dtype, ffi::Shape shape);
115 TVM_DLL static TensorInfo FromJSON(const ffi::ObjectRef& json_obj);
117};
118
119} // namespace meta_schedule
120} // namespace s_tir
121} // namespace tvm
122
123#endif // TVM_S_TIR_META_SCHEDULE_ARG_INFO_H_
TIR expressions.
TIR Function.
Managed reference class to IRModuleObj.
Definition module.h:292
The argument information.
Definition arg_info.h:35
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:50
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:79
ffi::Shape shape
The shape of the tensor.
Definition arg_info.h:84
static void RegisterReflection()
Definition arg_info.h:86
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:82
ffi::ObjectRef AsJSON() const
Converts the ArgInfo to its corresponding JSON representation.
Managed reference to TensorInfoObj.
Definition arg_info.h:102
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 FunctionObj.
Definition function.h:107
Parent compiler symbol visibility.
IRModule that holds the functions and type definitions.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analysis.h:41