tvm
tirx_stmt.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  */
23 #ifndef TVM_TIRX_TIRX_STMT_H_
24 #define TVM_TIRX_TIRX_STMT_H_
25 
26 #include <tvm/ir/op.h>
27 #include <tvm/tirx/stmt.h>
28 
29 namespace tvm {
30 namespace tirx {
31 
36  public:
37  TilePrimitiveCallNode(tvm::Op op, ffi::Array<ffi::Any> args,
38  ffi::Map<ffi::String, Buffer> workspace,
39  ffi::Map<ffi::String, ffi::Any> config, ffi::Optional<ffi::String> dispatch,
41  : op(std::move(op)),
42  args(std::move(args)),
43  workspace(std::move(workspace)),
44  config(std::move(config)),
45  dispatch(std::move(dispatch)),
46  scope(std::move(scope)) {}
47 
48  // tvm::Op which corresponds to the TIRX operator.
50 
51  // Arguments to the operator.
52  ffi::Array<ffi::Any> args;
53 
54  // Workspace (pre-allocated buffers) for the operator.
55  ffi::Map<ffi::String, Buffer> workspace;
56 
57  // Config for the operator/scheduler.
58  ffi::Map<ffi::String, ffi::Any> config;
59 
60  // Optional dispatch variant name registered via @register_dispatch.
61  ffi::Optional<ffi::String> dispatch{std::nullopt};
62 
63  // Cooperation scope of this call. Default thread (an unscoped call).
65 
66  static void RegisterReflection() {
67  namespace refl = tvm::ffi::reflection;
68  refl::ObjectDef<TilePrimitiveCallNode>()
69  .def_ro("op", &TilePrimitiveCallNode::op)
70  .def_ro("args", &TilePrimitiveCallNode::args)
71  .def_ro("workspace", &TilePrimitiveCallNode::workspace)
72  .def_ro("config", &TilePrimitiveCallNode::config)
73  .def_ro("dispatch", &TilePrimitiveCallNode::dispatch)
74  .def_ro("scope", &TilePrimitiveCallNode::scope);
75  }
76 
78 };
79 
84 class TilePrimitiveCall : public Stmt {
85  public:
86  TVM_DLL TilePrimitiveCall(tvm::Op op, ffi::Array<ffi::Any> args,
87  ffi::Map<ffi::String, Buffer> workspace = {},
88  ffi::Map<ffi::String, ffi::Any> config = {},
89  ffi::Optional<ffi::String> dispatch = std::nullopt,
90  ExecScope scope = ExecScope(ScopeKind::kThread));
91 
92  static bool IsValidOpCallArgType(const ffi::Any& arg);
93 
96 };
97 
98 } // namespace tirx
99 } // namespace tvm
100 
101 #endif // TVM_TIRX_TIRX_STMT_H_
Managed reference class to OpNode.
Definition: op.h:163
Definition: exec_scope.h:228
Base node of all statements.
Definition: stmt.h:41
Container of all statements.
Definition: stmt.h:64
TIRX TilePrimitiveCall stmt.
Definition: tirx_stmt.h:35
ffi::Optional< ffi::String > dispatch
Definition: tirx_stmt.h:61
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.TilePrimitiveCall", TilePrimitiveCallNode, StmtNode)
ffi::Map< ffi::String, Buffer > workspace
Definition: tirx_stmt.h:55
ffi::Array< ffi::Any > args
Definition: tirx_stmt.h:52
tvm::Op op
Definition: tirx_stmt.h:49
static void RegisterReflection()
Definition: tirx_stmt.h:66
TilePrimitiveCallNode(tvm::Op op, ffi::Array< ffi::Any > args, ffi::Map< ffi::String, Buffer > workspace, ffi::Map< ffi::String, ffi::Any > config, ffi::Optional< ffi::String > dispatch, ExecScope scope)
Definition: tirx_stmt.h:37
ExecScope scope
Definition: tirx_stmt.h:64
ffi::Map< ffi::String, ffi::Any > config
Definition: tirx_stmt.h:58
Managed reference to TilePrimitiveCallNode.
Definition: tirx_stmt.h:84
TVM_DEFINE_OBJECT_REF_COW_METHOD(TilePrimitiveCallNode)
static bool IsValidOpCallArgType(const ffi::Any &arg)
TilePrimitiveCall(tvm::Op op, ffi::Array< ffi::Any > args, ffi::Map< ffi::String, Buffer > workspace={}, ffi::Map< ffi::String, ffi::Any > config={}, ffi::Optional< ffi::String > dispatch=std::nullopt, ExecScope scope=ExecScope(ScopeKind::kThread))
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(TilePrimitiveCall, Stmt, TilePrimitiveCallNode)
Primitive operators(builtin intrinsics) and registry for them.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition: analyzer.h:40
TIR statements.