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 {
31using namespace tvm::prim;
32namespace meta_schedule {
33
35class ArgInfoNode : public ffi::Object {
36 public:
37 TVM_FFI_DECLARE_OBJECT_INFO("s_tir.meta_schedule.ArgInfo", ArgInfoNode, ffi::Object);
38
39 public:
41 virtual ~ArgInfoNode() = 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> FromPrimFunc(const tirx::PrimFunc& 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
80 public:
84 ffi::Shape shape;
85
86 static void RegisterReflection() {
87 namespace refl = tvm::ffi::reflection;
88 refl::ObjectDef<TensorInfoNode>()
89 .def_ro("dtype", &TensorInfoNode::dtype)
90 .def_ro("shape", &TensorInfoNode::shape);
91 }
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_
Managed reference class to IRModuleNode.
Definition module.h:255
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:59
The argument information.
Definition arg_info.h:35
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:50
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ArgInfo, ffi::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 ffi::Array< ArgInfo, void > FromPrimFunc(const tirx::PrimFunc &func)
Extract a list of the argument information from PrimFunc.
static ArgInfo FromJSON(const ffi::ObjectRef &json_obj)
Parse the argument information from a JSON object.
The tensor argument information.
Definition arg_info.h:79
static void RegisterReflection()
Definition arg_info.h:86
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)
DLDataType dtype
The data type of the tensor.
Definition arg_info.h:82
ffi::Shape shape
The shape of the tensor.
Definition arg_info.h:84
Managed reference to TensorInfoNode.
Definition arg_info.h:102
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(TensorInfo, ArgInfo, TensorInfoNode)
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 PrimFuncNode.
Definition function.h:105
TIR expressions.
IRModule that holds the functions and type definitions.
Definition builtin.h:25
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analyzer.h:40
TIR Function.