tvm
Loading...
Searching...
No Matches
operation.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
24#ifndef TVM_TE_OPERATION_H_
25#define TVM_TE_OPERATION_H_
26
27#include <tvm/ffi/reflection/registry.h>
28#include <tvm/ir/cow.h>
29#include <tvm/ir/prim/expr.h>
30#include <tvm/ir/prim/op.h>
31#include <tvm/sym/analyzer.h>
32#include <tvm/te/reduction.h>
33#include <tvm/te/tensor.h>
34#include <tvm/tirx/expr.h>
35#include <tvm/tirx/stmt.h>
36
37#include <string>
38#include <unordered_map>
39#include <utility>
40#include <vector>
41
42namespace tvm {
44namespace te {
45
46// Reduce operator
51class CommReducerNode : public ffi::Object {
52 public:
54 ffi::Array<PrimVar> lhs;
56 ffi::Array<PrimVar> rhs;
58 ffi::Array<PrimExpr> result;
64 ffi::Array<PrimExpr> identity_element;
66 ffi::Array<PrimExpr> operator()(ffi::Array<PrimExpr> a, ffi::Array<PrimExpr> b) const;
71 mutable Location loc = UnknownLoc();
72
73 static void RegisterReflection() {
74 namespace refl = tvm::ffi::reflection;
75 refl::ObjectDef<CommReducerNode>()
76 .def_ro("lhs", &CommReducerNode::lhs, refl::AttachFieldFlag::SEqHashDefPattern())
77 .def_ro("rhs", &CommReducerNode::rhs, refl::AttachFieldFlag::SEqHashDefPattern())
78 .def_ro("result", &CommReducerNode::result)
79 .def_ro("identity_element", &CommReducerNode::identity_element)
80 .def_ro("loc", &CommReducerNode::loc, refl::AttachFieldFlag::SEqHashIgnore());
81 }
82
83 static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindTreeNode;
84 TVM_FFI_DECLARE_OBJECT_INFO_FINAL("te.CommReducer", CommReducerNode, ffi::Object);
85};
86
91class CommReducer : public ffi::ObjectRef {
92 public:
93 TVM_DLL CommReducer(ffi::Array<PrimVar> lhs, ffi::Array<PrimVar> rhs, ffi::Array<PrimExpr> result,
94 ffi::Array<PrimExpr> identity_element, Location loc = UnknownLoc());
96};
97
99class ReduceNode : public OpaqueExprNode {
100 public:
103 explicit ReduceNode(ffi::UnsafeInit)
104 : combiner(ffi::UnsafeInit{}), condition(ffi::UnsafeInit{}) {}
105
109 ffi::Array<PrimExpr> source;
111 ffi::Array<PrimExpr> init;
113 ffi::Array<s_tir::IterVar> axis;
121
122 static void RegisterReflection() {
123 namespace refl = tvm::ffi::reflection;
124 refl::ObjectDef<ReduceNode>()
125 .def_ro("combiner", &ReduceNode::combiner)
126 .def_ro("source", &ReduceNode::source)
127 .def_ro("init", &ReduceNode::init)
128 .def_ro("axis", &ReduceNode::axis)
129 .def_ro("condition", &ReduceNode::condition)
130 .def_ro("value_index", &ReduceNode::value_index);
131 }
133};
134
139class Reduce : public PrimExpr {
140 public:
141 TVM_DLL Reduce(CommReducer combiner, ffi::Array<PrimExpr> src, ffi::Array<s_tir::IterVar> rdom,
142 ffi::Optional<PrimExpr> condition, int value_index, ffi::Array<PrimExpr> init,
143 Location loc = UnknownLoc());
144 explicit Reduce(ffi::ObjectPtr<ReduceNode> node) : PrimExpr(std::move(node)) {}
145
147 static constexpr bool _type_container_is_exact = true;
149};
150
155struct TensorDom {
156 // constructor
157 explicit TensorDom(int ndim) : data(ndim) {}
159 std::vector<std::vector<IntSet>> data;
160};
161
165class TVM_DLL OperationNode : public ffi::Object {
166 public:
168 std::string name;
170 std::string tag;
172 ffi::Map<ffi::String, ffi::Any> attrs;
173 // virtual destructor.
174 virtual ~OperationNode() {}
176 virtual int num_outputs() const = 0;
182 virtual PrimType output_dtype(size_t i) const = 0;
188 virtual ffi::Array<PrimExpr> output_shape(size_t i) const = 0;
193 virtual ffi::Array<Tensor> InputTensors() const = 0;
194
195 static void RegisterReflection() {
196 namespace refl = tvm::ffi::reflection;
197 refl::ObjectDef<OperationNode>()
198 .def_ro("name", &OperationNode::name)
199 .def_ro("tag", &OperationNode::tag)
200 .def_ro("attrs", &OperationNode::attrs);
201 }
202 TVM_FFI_DECLARE_OBJECT_INFO("te.Operation", OperationNode, ffi::Object);
203};
204
209 public:
211 ffi::Array<PrimExpr> shape;
214 // override behavior.
215 int num_outputs() const final;
216 PrimType output_dtype(size_t i) const final;
217 ffi::Array<PrimExpr> output_shape(size_t i) const final;
218 ffi::Array<Tensor> InputTensors() const final;
219
220 static void RegisterReflection() {
221 namespace refl = tvm::ffi::reflection;
222 refl::ObjectDef<PlaceholderOpNode>()
223 .def_ro("shape", &PlaceholderOpNode::shape)
224 .def_ro("dtype", &PlaceholderOpNode::dtype);
225 }
227};
228
233class PlaceholderOp : public Operation {
234 public:
235 TVM_DLL PlaceholderOp(std::string name, ffi::Array<PrimExpr> shape, PrimType dtype);
236
237 explicit PlaceholderOp(ffi::UnsafeInit tag, ffi::ObjectPtr<PlaceholderOpNode> node)
238 : Operation(tag) {
239 data_ = std::move(node);
240 }
241
243};
244
249class TVM_DLL BaseComputeOpNode : public OperationNode {
250 public:
252 ffi::Array<IterVar> axis;
254 ffi::Array<IterVar> reduce_axis;
255 // override functions
256 ffi::Array<PrimExpr> output_shape(size_t idx) const final;
257
258 static void RegisterReflection() {
259 namespace refl = tvm::ffi::reflection;
260 refl::ObjectDef<BaseComputeOpNode>()
261 .def_ro("axis", &BaseComputeOpNode::axis)
262 .def_ro("reduce_axis", &BaseComputeOpNode::reduce_axis);
263 }
265};
266
270class TVM_DLL ComputeOpNode : public BaseComputeOpNode {
271 public:
273 ffi::Array<PrimExpr> body;
276 // override functions
277 int num_outputs() const final;
278 PrimType output_dtype(size_t i) const final;
279 ffi::Array<Tensor> InputTensors() const final;
280
281 static void RegisterReflection() {
282 namespace refl = tvm::ffi::reflection;
283 refl::ObjectDef<ComputeOpNode>().def_ro("body", &ComputeOpNode::body);
284 }
286};
287
292class ComputeOp : public Operation {
293 public:
294 TVM_DLL ComputeOp(std::string name, std::string tag, ffi::Map<ffi::String, ffi::Any> attrs,
295 ffi::Array<IterVar> axis, ffi::Array<PrimExpr> body);
296
299};
300
304class ScanOpNode : public OperationNode {
305 public:
307 IterVar scan_axis{ffi::UnsafeInit{}};
309 ffi::Array<Tensor> init;
311 ffi::Array<Tensor> update;
313 ffi::Array<Tensor> state_placeholder;
318 ffi::Array<Tensor> inputs;
328 ffi::Array<IterVar> spatial_axis_;
331 // override behavior.
332 int num_outputs() const final;
333 PrimType output_dtype(size_t i) const final;
334 ffi::Array<PrimExpr> output_shape(size_t i) const final;
335 ffi::Array<Tensor> InputTensors() const final;
336
337 static void RegisterReflection() {
338 namespace refl = tvm::ffi::reflection;
339 refl::ObjectDef<ScanOpNode>()
340 .def_ro("scan_axis", &ScanOpNode::scan_axis)
341 .def_ro("init", &ScanOpNode::init)
342 .def_ro("update", &ScanOpNode::update)
343 .def_ro("state_placeholder", &ScanOpNode::state_placeholder)
344 .def_ro("inputs", &ScanOpNode::inputs)
345 .def_ro("spatial_axis_", &ScanOpNode::spatial_axis_);
346 }
348};
349
354class ScanOp : public Operation {
355 public:
356 TVM_DLL ScanOp(std::string name, std::string tag,
357 ffi::Optional<ffi::Map<ffi::String, ffi::Any>> attrs, IterVar axis,
358 ffi::Array<Tensor> init, ffi::Array<Tensor> update,
359 ffi::Array<Tensor> state_placeholder, ffi::Array<Tensor> input);
360
362};
363
368 public:
369 explicit ExternOpNode(SeqStmt body) : body(std::move(body)) {}
370 explicit ExternOpNode(ffi::UnsafeInit) : body(ffi::UnsafeInit{}) {}
371
373 ffi::Array<Tensor> inputs;
375 ffi::Array<TensorVar> input_placeholders;
377 ffi::Array<TensorVar> output_placeholders;
380
381 // override functions
382 int num_outputs() const final;
383 PrimType output_dtype(size_t i) const final;
384 ffi::Array<PrimExpr> output_shape(size_t i) const final;
385 ffi::Array<Tensor> InputTensors() const final;
386
387 static void RegisterReflection() {
388 namespace refl = tvm::ffi::reflection;
389 refl::ObjectDef<ExternOpNode>()
390 .def_ro("inputs", &ExternOpNode::inputs)
391 .def_ro("input_placeholders", &ExternOpNode::input_placeholders)
392 .def_ro("output_placeholders", &ExternOpNode::output_placeholders)
393 .def_ro("body", &ExternOpNode::body);
394 }
396};
397
402class ExternOp : public Operation {
403 public:
404 TVM_DLL ExternOp(std::string name, std::string tag, ffi::Map<ffi::String, ffi::Any> attrs,
405 ffi::Array<Tensor> inputs, ffi::Array<TensorVar> input_placeholders,
406 ffi::Array<TensorVar> output_placeholders, SeqStmt body);
407
409};
410
416TVM_DLL PrimVar var(std::string name_hint, PrimType t = PrimType::Int(32));
417
424TVM_DLL IterVar thread_axis(Range dom, std::string tag);
425
432TVM_DLL IterVar reduce_axis(Range dom, std::string name = "rv");
433
435using FCompute = std::function<PrimExpr(const ffi::Array<PrimVar>& i)>;
436
438using FBatchCompute = std::function<ffi::Array<PrimExpr>(const ffi::Array<PrimVar>& i)>;
439
446TVM_DLL Tensor placeholder(ffi::Array<PrimExpr> shape, PrimType dtype = PrimType::Float(32),
447 std::string name = "placeholder");
448
458TVM_DLL Tensor compute(ffi::Array<PrimExpr> shape, FCompute fcompute, std::string name = "tensor",
459 std::string tag = "", ffi::Map<ffi::String, ffi::Any> attrs = {});
460
470TVM_DLL ffi::Array<Tensor> compute(ffi::Array<PrimExpr> shape, FBatchCompute fcompute,
471 std::string name = "tensor", std::string tag = "",
472 ffi::Map<ffi::String, ffi::Any> attrs = {});
473
486TVM_DLL ffi::Array<Tensor> scan(ffi::Array<Tensor> init, ffi::Array<Tensor> update,
487 ffi::Array<Tensor> state_placeholder,
488 ffi::Array<Tensor> inputs = ffi::Array<Tensor>(),
489 std::string name = "scan", std::string tag = "",
490 ffi::Map<ffi::String, ffi::Any> attrs = {});
491
492// same as compute, specialized for different fcompute function
493inline Tensor compute(ffi::Array<PrimExpr> shape, std::function<PrimExpr(PrimVar)> f,
494 std::string name = "tensor", std::string tag = "",
495 ffi::Map<ffi::String, ffi::Any> attrs = {}) {
496 FCompute fc = [f](const ffi::Array<PrimVar>& i) { return f(i[0]); };
497 return compute(shape, fc, name, tag, attrs);
498}
499inline Tensor compute(ffi::Array<PrimExpr> shape, std::function<PrimExpr(PrimVar, PrimVar)> f,
500 std::string name = "tensor", std::string tag = "",
501 ffi::Map<ffi::String, ffi::Any> attrs = {}) {
502 FCompute fc = [f](const ffi::Array<PrimVar>& i) { return f(i[0], i[1]); };
503 return compute(shape, fc, name, tag, attrs);
504}
505inline Tensor compute(ffi::Array<PrimExpr> shape,
506 std::function<PrimExpr(PrimVar, PrimVar, PrimVar)> f,
507 std::string name = "tensor", std::string tag = "",
508 ffi::Map<ffi::String, ffi::Any> attrs = {}) {
509 FCompute fc = [f](const ffi::Array<PrimVar>& i) { return f(i[0], i[1], i[2]); };
510 return compute(shape, fc, name, tag, attrs);
511}
512inline Tensor compute(ffi::Array<PrimExpr> shape,
513 std::function<PrimExpr(PrimVar, PrimVar, PrimVar, PrimVar)> f,
514 std::string name = "tensor", std::string tag = "",
515 ffi::Map<ffi::String, ffi::Any> attrs = {}) {
516 FCompute fc = [f](const ffi::Array<PrimVar>& i) { return f(i[0], i[1], i[2], i[3]); };
517 return compute(shape, fc, name, tag, attrs);
518}
519
520// inline function.
522 return static_cast<const OperationNode*>(get());
523}
524} // namespace te
525
526namespace ffi {
527
528template <>
529inline constexpr bool object_ref_contains_v<PrimExpr, te::ReduceNode> = true;
530
531} // namespace ffi
532} // namespace tvm
533#endif // TVM_TE_OPERATION_H_
Algebra expression simplifications.
Non-nullable source-location metadata.
Definition location.h:91
Base node for opaque construction-time expressions.
Definition base_expr.h:394
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition base_expr.h:447
Definition base_expr.h:161
static TVM_TIRX_DLL PrimType Void()
Construct the void sentinel type, encoded as handle(0, 0).
static TVM_TIRX_DLL PrimType Int(int bits, int lanes=1)
Construct a signed integer type with fixed lanes.
static TVM_TIRX_DLL PrimType Float(int bits, int lanes=1)
Construct a floating-point type with fixed lanes.
Checked scalar view over a VarNode.
Definition expr.h:742
Range container
Definition expr.h:1025
Sequence statement.
Definition stmt.h:92
Reference to the shared immutable unknown location.
Definition location.h:105
Iteration Variable, represents an iteration over an integer interval.
Definition iter_var.h:147
A Compute op that compute a tensor on certain domain. This is the base class for ComputeOp (operating...
Definition operation.h:249
ffi::Array< IterVar > reduce_axis
IterVar on each reduction axis, if the body is a Reduce.
Definition operation.h:254
static void RegisterReflection()
Definition operation.h:258
ffi::Array< PrimExpr > output_shape(size_t idx) const final
Get shape of i-th output tensor.
TVM_FFI_DECLARE_OBJECT_INFO("te.BaseComputeOp", BaseComputeOpNode, OperationNode)
ffi::Array< IterVar > axis
IterVar on each axis.
Definition operation.h:252
A commutative reducer node to represent a commutative binary operator with identity element.
Definition operation.h:51
ffi::Array< PrimVar > rhs
The right argument of reducer.
Definition operation.h:56
Location loc
Location that points to the original source code. Reserved debug information.
Definition operation.h:71
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("te.CommReducer", CommReducerNode, ffi::Object)
ffi::Array< PrimExpr > operator()(ffi::Array< PrimExpr > a, ffi::Array< PrimExpr > b) const
Function call operator to combine a and b.
ffi::Array< PrimExpr > identity_element
The identity element of reducer, which leaves other elements unchanged when combined with it,...
Definition operation.h:64
ffi::Array< PrimExpr > result
The result of reducer.
Definition operation.h:58
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition operation.h:83
ffi::Array< PrimVar > lhs
The left argument of reducer.
Definition operation.h:54
static void RegisterReflection()
Definition operation.h:73
Managed reference to CommReducerNode.
Definition operation.h:91
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(CommReducer, ffi::ObjectRef, CommReducerNode)
CommReducer(ffi::Array< PrimVar > lhs, ffi::Array< PrimVar > rhs, ffi::Array< PrimExpr > result, ffi::Array< PrimExpr > identity_element, Location loc=UnknownLoc())
A Compute op that compute a tensor on certain domain.
Definition operation.h:270
ComputeOpNode()
constructor
Definition operation.h:275
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("te.ComputeOp", ComputeOpNode, BaseComputeOpNode)
int num_outputs() const final
ffi::Array< PrimExpr > body
the compute expression
Definition operation.h:273
Managed reference to ComputeOpNode.
Definition operation.h:292
ComputeOp(std::string name, std::string tag, ffi::Map< ffi::String, ffi::Any > attrs, ffi::Array< IterVar > axis, ffi::Array< PrimExpr > body)
TVM_DEFINE_OBJECT_REF_COW_METHOD(ComputeOpNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ComputeOp, Operation, ComputeOpNode)
External computation that cannot be splitted.
Definition operation.h:367
int num_outputs() const final
ExternOpNode(SeqStmt body)
Definition operation.h:369
ffi::Array< Tensor > inputs
The input tensors.
Definition operation.h:373
PrimType output_dtype(size_t i) const final
Get the primitive element type of the i-th output tensor.
static void RegisterReflection()
Definition operation.h:387
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("te.ExternOp", ExternOpNode, OperationNode)
SeqStmt body
the statement that generates the computation.
Definition operation.h:379
ffi::Array< TensorVar > input_placeholders
Symbolic placeholder representation of inputs.
Definition operation.h:375
ffi::Array< TensorVar > output_placeholders
Symbolic placeholder representation of outputs.
Definition operation.h:377
ExternOpNode(ffi::UnsafeInit)
Definition operation.h:370
ffi::Array< Tensor > InputTensors() const final
List all the input Tensors.
ffi::Array< PrimExpr > output_shape(size_t i) const final
Get shape of i-th output tensor.
Managed reference to ExternOpNode.
Definition operation.h:402
ExternOp(std::string name, std::string tag, ffi::Map< ffi::String, ffi::Any > attrs, ffi::Array< Tensor > inputs, ffi::Array< TensorVar > input_placeholders, ffi::Array< TensorVar > output_placeholders, SeqStmt body)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ExternOp, Operation, ExternOpNode)
Base class of all operation nodes.
Definition operation.h:165
TVM_FFI_DECLARE_OBJECT_INFO("te.Operation", OperationNode, ffi::Object)
virtual ~OperationNode()
Definition operation.h:174
static void RegisterReflection()
Definition operation.h:195
virtual PrimType output_dtype(size_t i) const =0
Get the primitive element type of the i-th output tensor.
virtual int num_outputs() const =0
virtual ffi::Array< Tensor > InputTensors() const =0
List all the input Tensors.
virtual ffi::Array< PrimExpr > output_shape(size_t i) const =0
Get shape of i-th output tensor.
ffi::Map< ffi::String, ffi::Any > attrs
additional attributes of the operation
Definition operation.h:172
std::string name
optional name of the operation
Definition operation.h:168
std::string tag
optional tag of the operation
Definition operation.h:170
Operation that produces tensors.
Definition tensor.h:63
const OperationNode * operator->() const
access the internal node container
Definition operation.h:521
A placeholder op represents an input placeholder.
Definition operation.h:208
ffi::Array< Tensor > InputTensors() const final
List all the input Tensors.
TVM_FFI_DECLARE_OBJECT_INFO("te.PlaceholderOp", PlaceholderOpNode, OperationNode)
static void RegisterReflection()
Definition operation.h:220
ffi::Array< PrimExpr > shape
The shape of the input.
Definition operation.h:211
int num_outputs() const final
ffi::Array< PrimExpr > output_shape(size_t i) const final
Get shape of i-th output tensor.
PrimType dtype
The dtype of the input.
Definition operation.h:213
PrimType output_dtype(size_t i) const final
Get the primitive element type of the i-th output tensor.
Managed reference to PlaceholderOpNode.
Definition operation.h:233
PlaceholderOp(ffi::UnsafeInit tag, ffi::ObjectPtr< PlaceholderOpNode > node)
Definition operation.h:237
PlaceholderOp(std::string name, ffi::Array< PrimExpr > shape, PrimType dtype)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(PlaceholderOp, Operation, PlaceholderOpNode)
Reduction operator.
Definition operation.h:99
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("te.Reduce", ReduceNode, OpaqueExprNode)
ffi::Array< PrimExpr > init
The init operand.
Definition operation.h:111
int value_index
the index of this reduce node
Definition operation.h:120
ffi::Array< PrimExpr > source
The source operand.
Definition operation.h:109
ReduceNode(ffi::UnsafeInit)
Definition operation.h:103
CommReducer combiner
The commutative combiner.
Definition operation.h:107
ffi::Array< s_tir::IterVar > axis
The reduction axis.
Definition operation.h:113
ReduceNode(CommReducer combiner, PrimExpr condition)
Definition operation.h:101
PrimExpr condition
Predicate on the reduction Only add the body to reduction if condition is true.
Definition operation.h:118
static void RegisterReflection()
Definition operation.h:122
Managed reference to ReduceNode.
Definition operation.h:139
Reduce(ffi::ObjectPtr< ReduceNode > node)
Definition operation.h:144
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Reduce, PrimExpr, ReduceNode)
TVM_DEFINE_OBJECT_REF_COW_METHOD(ReduceNode)
static constexpr bool _type_container_is_exact
Definition operation.h:147
Reduce(CommReducer combiner, ffi::Array< PrimExpr > src, ffi::Array< s_tir::IterVar > rdom, ffi::Optional< PrimExpr > condition, int value_index, ffi::Array< PrimExpr > init, Location loc=UnknownLoc())
Symbolic scan.
Definition operation.h:304
ffi::Array< Tensor > state_placeholder
The placeholder to refer as states in update.
Definition operation.h:313
ScanOpNode()
constructor
Definition operation.h:330
int num_outputs() const final
ffi::Array< Tensor > init
the initialization tensors
Definition operation.h:309
ffi::Array< Tensor > update
the update function represented by tensor
Definition operation.h:311
ffi::Array< Tensor > inputs
the inputs to the scan, these are optionally provided But they can be helpful to provide hints to spe...
Definition operation.h:318
ffi::Array< Tensor > InputTensors() const final
List all the input Tensors.
static void RegisterReflection()
Definition operation.h:337
IterVar scan_axis
IterVar to scan over.
Definition operation.h:307
ffi::Array< PrimExpr > output_shape(size_t i) const final
Get shape of i-th output tensor.
PrimType output_dtype(size_t i) const final
Get the primitive element type of the i-th output tensor.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("te.ScanOp", ScanOpNode, OperationNode)
ffi::Array< IterVar > spatial_axis_
Spatial axis to indicate spatial dimension of each output. They corresponds to flattened spatial axis...
Definition operation.h:328
Managed reference to ScanOpNode.
Definition operation.h:354
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ScanOp, Operation, ScanOpNode)
ScanOp(std::string name, std::string tag, ffi::Optional< ffi::Map< ffi::String, ffi::Any > > attrs, IterVar axis, ffi::Array< Tensor > init, ffi::Array< Tensor > update, ffi::Array< Tensor > state_placeholder, ffi::Array< Tensor > input)
Tensor structure representing a possible input, or intermediate computation result.
Definition tensor.h:111
Copy-on-write helper macro for IR ffi::ObjectRef types.
TIR expressions.
Shared primitive construction and constant helpers.
PrimVar var(std::string name_hint, PrimType t=PrimType::Int(32))
Construct a new Var expression.
ffi::Array< Tensor > scan(ffi::Array< Tensor > init, ffi::Array< Tensor > update, ffi::Array< Tensor > state_placeholder, ffi::Array< Tensor > inputs=ffi::Array< Tensor >(), std::string name="scan", std::string tag="", ffi::Map< ffi::String, ffi::Any > attrs={})
Construct new tensors by scan.
Tensor placeholder(ffi::Array< PrimExpr > shape, PrimType dtype=PrimType::Float(32), std::string name="placeholder")
create a place holder tensor.
std::function< ffi::Array< PrimExpr >(const ffi::Array< PrimVar > &i)> FBatchCompute
The compute function to specify the inputs source of Tensors.
Definition operation.h:438
std::function< PrimExpr(const ffi::Array< PrimVar > &i)> FCompute
The compute function to specify the input source of a Tensor.
Definition operation.h:435
IterVar thread_axis(Range dom, std::string tag)
Create a new IterVar that represents an axis in thread.
IterVar reduce_axis(Range dom, std::string name="rv")
Create a new IterVar for reduction operations.
Tensor compute(ffi::Array< PrimExpr > shape, FCompute fcompute, std::string name="tensor", std::string tag="", ffi::Map< ffi::String, ffi::Any > attrs={})
Construct a new tensor by computing over shape, using the computation rule: result_tensor[axis] = fco...
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition attr.h:23
Temporary data structure to store union of bounds of each axis of Tensor.
Definition operation.h:155
TensorDom(int ndim)
Definition operation.h:157
std::vector< std::vector< IntSet > > data
The domain data.
Definition operation.h:159
Tensor-expression reduction constructors.
Dataflow tensor object.
TIRx tensor expressions and construction helpers.
TIRx statements and shared statement entry header.