tvm
Loading...
Searching...
No Matches
expr.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// Acknowledgement: Many low-level IR nodes originate from Halide.
25#ifndef TVM_IR_PRIM_EXPR_H_
26#define TVM_IR_PRIM_EXPR_H_
27
28#include <tvm/ffi/container/array.h>
29#include <tvm/ffi/container/map.h>
30#include <tvm/ffi/dtype.h>
31#include <tvm/ffi/string.h>
32#include <tvm/ir/attrs.h>
33#include <tvm/ir/cow.h>
34#include <tvm/ir/expr.h>
37#include <tvm/runtime/base.h>
38
39#include <algorithm>
40#include <iostream>
41#include <limits>
42#include <string>
43#include <unordered_map>
44#include <utility>
45
46namespace tvm {
47namespace prim {
48
51
56class CastNode : public ExprNode {
57 public:
58 explicit CastNode(PrimExpr value) : value(std::move(value)) {}
59 explicit CastNode(ffi::UnsafeInit tag) : value(tag) {}
60
63 static void RegisterReflection() {
64 namespace refl = tvm::ffi::reflection;
65 refl::ObjectDef<CastNode>().def_ro("value", &CastNode::value);
66 }
68};
69
74class Cast : public PrimExpr {
75 public:
77 explicit Cast(ffi::ObjectPtr<CastNode> node) : PrimExpr(std::move(node)) {}
78
80 static constexpr bool _type_container_is_exact = true;
82};
83
88template <typename T>
89class BinaryOpNode : public ExprNode {
90 public:
91 BinaryOpNode(PrimExpr a, PrimExpr b) : a(std::move(a)), b(std::move(b)) {}
92 explicit BinaryOpNode(ffi::UnsafeInit tag) : a(tag), b(tag) {}
93
98 static void RegisterReflection() {
99 namespace refl = tvm::ffi::reflection;
100 refl::ObjectDef<T>().def_ro("a", &T::a).def_ro("b", &T::b);
101 }
102 static const constexpr int _type_child_slots [[maybe_unused]] = 0;
103 static const constexpr bool _type_final [[maybe_unused]] = true;
105};
106
108class AddNode : public BinaryOpNode<AddNode> {
109 public:
110 using BinaryOpNode<AddNode>::BinaryOpNode;
111 static constexpr const char* _type_key = "prim.Add";
112};
113
118class Add : public PrimExpr {
119 public:
121 explicit Add(ffi::ObjectPtr<AddNode> node) : PrimExpr(std::move(node)) {}
122
124 static constexpr bool _type_container_is_exact = true;
126};
127
129class LShiftNode : public BinaryOpNode<LShiftNode> {
130 public:
131 using BinaryOpNode<LShiftNode>::BinaryOpNode;
132 static constexpr const char* _type_key = "prim.LShift";
133};
134
139class LShift : public PrimExpr {
140 public:
142 explicit LShift(ffi::ObjectPtr<LShiftNode> node) : PrimExpr(std::move(node)) {}
143
145 static constexpr bool _type_container_is_exact = true;
147};
148
150class RShiftNode : public BinaryOpNode<RShiftNode> {
151 public:
152 using BinaryOpNode<RShiftNode>::BinaryOpNode;
153 static constexpr const char* _type_key = "prim.RShift";
154};
155
160class RShift : public PrimExpr {
161 public:
163 explicit RShift(ffi::ObjectPtr<RShiftNode> node) : PrimExpr(std::move(node)) {}
164
166 static constexpr bool _type_container_is_exact = true;
168};
169
171class BitwiseAndNode : public BinaryOpNode<BitwiseAndNode> {
172 public:
173 using BinaryOpNode<BitwiseAndNode>::BinaryOpNode;
174 static constexpr const char* _type_key = "prim.BitwiseAnd";
175};
176
181class BitwiseAnd : public PrimExpr {
182 public:
184 explicit BitwiseAnd(ffi::ObjectPtr<BitwiseAndNode> node) : PrimExpr(std::move(node)) {}
185
187 static constexpr bool _type_container_is_exact = true;
189};
190
192class BitwiseOrNode : public BinaryOpNode<BitwiseOrNode> {
193 public:
194 using BinaryOpNode<BitwiseOrNode>::BinaryOpNode;
195 static constexpr const char* _type_key = "prim.BitwiseOr";
196};
197
202class BitwiseOr : public PrimExpr {
203 public:
205 explicit BitwiseOr(ffi::ObjectPtr<BitwiseOrNode> node) : PrimExpr(std::move(node)) {}
206
208 static constexpr bool _type_container_is_exact = true;
210};
211
213class BitwiseXorNode : public BinaryOpNode<BitwiseXorNode> {
214 public:
215 using BinaryOpNode<BitwiseXorNode>::BinaryOpNode;
216 static constexpr const char* _type_key = "prim.BitwiseXor";
217};
218
223class BitwiseXor : public PrimExpr {
224 public:
226 explicit BitwiseXor(ffi::ObjectPtr<BitwiseXorNode> node) : PrimExpr(std::move(node)) {}
227
229 static constexpr bool _type_container_is_exact = true;
231};
232
234class SubNode : public BinaryOpNode<SubNode> {
235 public:
236 using BinaryOpNode<SubNode>::BinaryOpNode;
237 static constexpr const char* _type_key = "prim.Sub";
238};
239
244class Sub : public PrimExpr {
245 public:
247
248 explicit Sub(ffi::ObjectPtr<SubNode> node) : PrimExpr(std::move(node)) {}
249
251 static constexpr bool _type_container_is_exact = true;
253};
254
256class MulNode : public BinaryOpNode<MulNode> {
257 public:
258 using BinaryOpNode<MulNode>::BinaryOpNode;
259 static constexpr const char* _type_key = "prim.Mul";
260};
261
266class Mul : public PrimExpr {
267 public:
269 explicit Mul(ffi::ObjectPtr<MulNode> node) : PrimExpr(std::move(node)) {}
270
272 static constexpr bool _type_container_is_exact = true;
274};
275
280class DivNode : public BinaryOpNode<DivNode> {
281 public:
282 using BinaryOpNode<DivNode>::BinaryOpNode;
283 static constexpr const char* _type_key = "prim.Div";
284};
285
290class Div : public PrimExpr {
291 public:
293 explicit Div(ffi::ObjectPtr<DivNode> node) : PrimExpr(std::move(node)) {}
294
296 static constexpr bool _type_container_is_exact = true;
298};
299
304class ModNode : public BinaryOpNode<ModNode> {
305 public:
306 using BinaryOpNode<ModNode>::BinaryOpNode;
307 static constexpr const char* _type_key = "prim.Mod";
308};
309
314class Mod : public PrimExpr {
315 public:
317 explicit Mod(ffi::ObjectPtr<ModNode> node) : PrimExpr(std::move(node)) {}
318
320 static constexpr bool _type_container_is_exact = true;
322};
323
325class FloorDivNode : public BinaryOpNode<FloorDivNode> {
326 public:
327 using BinaryOpNode<FloorDivNode>::BinaryOpNode;
328 static constexpr const char* _type_key = "prim.FloorDiv";
329};
330
335class FloorDiv : public PrimExpr {
336 public:
338 explicit FloorDiv(ffi::ObjectPtr<FloorDivNode> node) : PrimExpr(std::move(node)) {}
339
341 static constexpr bool _type_container_is_exact = true;
343};
344
346class FloorModNode : public BinaryOpNode<FloorModNode> {
347 public:
348 using BinaryOpNode<FloorModNode>::BinaryOpNode;
349 static constexpr const char* _type_key = "prim.FloorMod";
350};
351
356class FloorMod : public PrimExpr {
357 public:
359 explicit FloorMod(ffi::ObjectPtr<FloorModNode> node) : PrimExpr(std::move(node)) {}
360
362 static constexpr bool _type_container_is_exact = true;
364};
365
367class MinNode : public BinaryOpNode<MinNode> {
368 public:
369 using BinaryOpNode<MinNode>::BinaryOpNode;
370 static constexpr const char* _type_key = "prim.Min";
371};
372
377class Min : public PrimExpr {
378 public:
380 explicit Min(ffi::ObjectPtr<MinNode> node) : PrimExpr(std::move(node)) {}
381
383 static constexpr bool _type_container_is_exact = true;
385};
386
388class MaxNode : public BinaryOpNode<MaxNode> {
389 public:
390 using BinaryOpNode<MaxNode>::BinaryOpNode;
391 static constexpr const char* _type_key = "prim.Max";
392};
393
398class Max : public PrimExpr {
399 public:
401 explicit Max(ffi::ObjectPtr<MaxNode> node) : PrimExpr(std::move(node)) {}
402
404 static constexpr bool _type_container_is_exact = true;
406};
407
412template <typename T>
413class CmpOpNode : public ExprNode {
414 public:
415 CmpOpNode(PrimExpr a, PrimExpr b) : a(std::move(a)), b(std::move(b)) {}
416 explicit CmpOpNode(ffi::UnsafeInit tag) : a(tag), b(tag) {}
417
422 static void RegisterReflection() {
423 namespace refl = tvm::ffi::reflection;
424 refl::ObjectDef<T>().def_ro("a", &T::a).def_ro("b", &T::b);
425 }
426 static const constexpr int _type_child_slots [[maybe_unused]] = 0;
427 static const constexpr bool _type_final [[maybe_unused]] = true;
429};
430
432class EQNode : public CmpOpNode<EQNode> {
433 public:
434 using CmpOpNode<EQNode>::CmpOpNode;
435 static constexpr const char* _type_key = "prim.EQ";
436};
437
442class EQ : public PrimExpr {
443 public:
445 explicit EQ(ffi::ObjectPtr<EQNode> node) : PrimExpr(std::move(node)) {}
446
448 static constexpr bool _type_container_is_exact = true;
450};
451
453class NENode : public CmpOpNode<NENode> {
454 public:
455 using CmpOpNode<NENode>::CmpOpNode;
456 static constexpr const char* _type_key = "prim.NE";
457};
458
463class NE : public PrimExpr {
464 public:
466 explicit NE(ffi::ObjectPtr<NENode> node) : PrimExpr(std::move(node)) {}
467
469 static constexpr bool _type_container_is_exact = true;
471};
472
474class LTNode : public CmpOpNode<LTNode> {
475 public:
476 using CmpOpNode<LTNode>::CmpOpNode;
477 static constexpr const char* _type_key = "prim.LT";
478};
479
484class LT : public PrimExpr {
485 public:
487 explicit LT(ffi::ObjectPtr<LTNode> node) : PrimExpr(std::move(node)) {}
488
490 static constexpr bool _type_container_is_exact = true;
492};
493
495struct LENode : public CmpOpNode<LENode> {
496 public:
497 using CmpOpNode<LENode>::CmpOpNode;
498 static constexpr const char* _type_key = "prim.LE";
499};
500
505class LE : public PrimExpr {
506 public:
508 explicit LE(ffi::ObjectPtr<LENode> node) : PrimExpr(std::move(node)) {}
509
511 static constexpr bool _type_container_is_exact = true;
513};
514
516class GTNode : public CmpOpNode<GTNode> {
517 public:
518 using CmpOpNode<GTNode>::CmpOpNode;
519 static constexpr const char* _type_key = "prim.GT";
520};
521
526class GT : public PrimExpr {
527 public:
529 explicit GT(ffi::ObjectPtr<GTNode> node) : PrimExpr(std::move(node)) {}
530
532 static constexpr bool _type_container_is_exact = true;
534};
535
537class GENode : public CmpOpNode<GENode> {
538 public:
539 using CmpOpNode<GENode>::CmpOpNode;
540 static constexpr const char* _type_key = "prim.GE";
541};
542
547class GE : public PrimExpr {
548 public:
550 explicit GE(ffi::ObjectPtr<GENode> node) : PrimExpr(std::move(node)) {}
551
553 static constexpr bool _type_container_is_exact = true;
555};
556
558class AndNode : public ExprNode {
559 public:
560 AndNode(PrimExpr a, PrimExpr b) : a(std::move(a)), b(std::move(b)) {}
561 explicit AndNode(ffi::UnsafeInit tag) : a(tag), b(tag) {}
562
567 static void RegisterReflection() {
568 namespace refl = tvm::ffi::reflection;
569 refl::ObjectDef<AndNode>().def_ro("a", &AndNode::a).def_ro("b", &AndNode::b);
570 }
572};
573
578class And : public PrimExpr {
579 public:
581 explicit And(ffi::ObjectPtr<AndNode> node) : PrimExpr(std::move(node)) {}
582
584 static constexpr bool _type_container_is_exact = true;
586};
587
589class OrNode : public ExprNode {
590 public:
591 OrNode(PrimExpr a, PrimExpr b) : a(std::move(a)), b(std::move(b)) {}
592 explicit OrNode(ffi::UnsafeInit tag) : a(tag), b(tag) {}
593
598 static void RegisterReflection() {
599 namespace refl = tvm::ffi::reflection;
600 refl::ObjectDef<OrNode>().def_ro("a", &OrNode::a).def_ro("b", &OrNode::b);
601 }
603};
604
609class Or : public PrimExpr {
610 public:
612 explicit Or(ffi::ObjectPtr<OrNode> node) : PrimExpr(std::move(node)) {}
613
615 static constexpr bool _type_container_is_exact = true;
617};
618
620class NotNode : public ExprNode {
621 public:
622 explicit NotNode(PrimExpr a) : a(std::move(a)) {}
623 explicit NotNode(ffi::UnsafeInit tag) : a(tag) {}
624
627 static void RegisterReflection() {
628 namespace refl = tvm::ffi::reflection;
629 refl::ObjectDef<NotNode>().def_ro("a", &NotNode::a);
630 }
632};
633
638class Not : public PrimExpr {
639 public:
641 explicit Not(ffi::ObjectPtr<NotNode> node) : PrimExpr(std::move(node)) {}
642
644 static constexpr bool _type_container_is_exact = true;
646};
647
649class BitwiseNotNode : public ExprNode {
650 public:
651 explicit BitwiseNotNode(PrimExpr a) : a(std::move(a)) {}
652 explicit BitwiseNotNode(ffi::UnsafeInit tag) : a(tag) {}
653
656 static void RegisterReflection() {
657 namespace refl = tvm::ffi::reflection;
658 refl::ObjectDef<BitwiseNotNode>().def_ro("a", &BitwiseNotNode::a);
659 }
661};
662
667class BitwiseNot : public PrimExpr {
668 public:
670 explicit BitwiseNot(ffi::ObjectPtr<BitwiseNotNode> node) : PrimExpr(std::move(node)) {}
671
673 static constexpr bool _type_container_is_exact = true;
675};
676
684class SelectNode : public ExprNode {
685 public:
690 explicit SelectNode(ffi::UnsafeInit tag) : condition(tag), true_value(tag), false_value(tag) {}
691
698 static void RegisterReflection() {
699 namespace refl = tvm::ffi::reflection;
700 refl::ObjectDef<SelectNode>()
701 .def_ro("condition", &SelectNode::condition)
702 .def_ro("true_value", &SelectNode::true_value)
703 .def_ro("false_value", &SelectNode::false_value);
704 }
706};
707
712class Select : public PrimExpr {
713 public:
714 TVM_TIRX_DLL Select(PrimExpr condition, PrimExpr true_value, PrimExpr false_value,
715 Location loc = UnknownLoc());
716
717 explicit Select(ffi::ObjectPtr<SelectNode> node) : PrimExpr(std::move(node)) {}
718
720 static constexpr bool _type_container_is_exact = true;
722};
723
727class LetNode : public ExprNode {
728 public:
730 : var(std::move(var)), value(std::move(value)), body(std::move(body)) {}
731 explicit LetNode(ffi::UnsafeInit tag) : var(tag), value(tag), body(tag) {}
732
739 static void RegisterReflection() {
740 namespace refl = tvm::ffi::reflection;
741 refl::ObjectDef<LetNode>()
742 .def_ro("var", &LetNode::var, refl::AttachFieldFlag::SEqHashDefSimple())
743 .def_ro("value", &LetNode::value)
744 .def_ro("body", &LetNode::body);
745 }
747};
748
753class Let : public PrimExpr {
754 public:
756 explicit Let(ffi::ObjectPtr<LetNode> node) : PrimExpr(std::move(node)) {}
757
759 static constexpr bool _type_container_is_exact = true;
761};
762
763/*
764 * \brief Template function to convert Map to unordered_map
765 * Sometimes useful for API gluing when internal uses unordered_map
766 * \param dmap The container map
767 * \return The corresponding unordered_map.
768 * \tparam K the key of the Map.
769 * \tparam V the value of the Map.
770 */
771template <typename K, typename V>
772inline std::unordered_map<K, V> as_unordered_map(const ffi::Map<K, V>& dmap) {
773 std::unordered_map<K, V> ret;
774 for (auto kv : dmap) {
775 ret[kv.first] = kv.second;
776 }
777 return ret;
778}
779
796 public:
797 TVM_TIRX_DLL bool operator()(const PrimExpr& lhs, const PrimExpr& rhs) const;
798};
799
800} // namespace prim
801
802namespace ffi {
803
804template <>
805inline constexpr bool object_ref_contains_v<PrimExpr, prim::CastNode> = true;
806template <>
807inline constexpr bool object_ref_contains_v<PrimExpr, prim::AddNode> = true;
808template <>
809inline constexpr bool object_ref_contains_v<PrimExpr, prim::BitwiseNotNode> = true;
810template <>
811inline constexpr bool object_ref_contains_v<PrimExpr, prim::BitwiseXorNode> = true;
812template <>
813inline constexpr bool object_ref_contains_v<PrimExpr, prim::BitwiseOrNode> = true;
814template <>
815inline constexpr bool object_ref_contains_v<PrimExpr, prim::BitwiseAndNode> = true;
816template <>
817inline constexpr bool object_ref_contains_v<PrimExpr, prim::RShiftNode> = true;
818template <>
819inline constexpr bool object_ref_contains_v<PrimExpr, prim::LShiftNode> = true;
820template <>
821inline constexpr bool object_ref_contains_v<PrimExpr, prim::SubNode> = true;
822template <>
823inline constexpr bool object_ref_contains_v<PrimExpr, prim::MulNode> = true;
824template <>
825inline constexpr bool object_ref_contains_v<PrimExpr, prim::DivNode> = true;
826template <>
827inline constexpr bool object_ref_contains_v<PrimExpr, prim::ModNode> = true;
828template <>
829inline constexpr bool object_ref_contains_v<PrimExpr, prim::FloorDivNode> = true;
830template <>
831inline constexpr bool object_ref_contains_v<PrimExpr, prim::FloorModNode> = true;
832template <>
833inline constexpr bool object_ref_contains_v<PrimExpr, prim::MinNode> = true;
834template <>
835inline constexpr bool object_ref_contains_v<PrimExpr, prim::MaxNode> = true;
836template <>
837inline constexpr bool object_ref_contains_v<PrimExpr, prim::EQNode> = true;
838template <>
839inline constexpr bool object_ref_contains_v<PrimExpr, prim::NENode> = true;
840template <>
841inline constexpr bool object_ref_contains_v<PrimExpr, prim::LTNode> = true;
842template <>
843inline constexpr bool object_ref_contains_v<PrimExpr, prim::LENode> = true;
844template <>
845inline constexpr bool object_ref_contains_v<PrimExpr, prim::GTNode> = true;
846template <>
847inline constexpr bool object_ref_contains_v<PrimExpr, prim::GENode> = true;
848template <>
849inline constexpr bool object_ref_contains_v<PrimExpr, prim::AndNode> = true;
850template <>
851inline constexpr bool object_ref_contains_v<PrimExpr, prim::OrNode> = true;
852template <>
853inline constexpr bool object_ref_contains_v<PrimExpr, prim::NotNode> = true;
854template <>
855inline constexpr bool object_ref_contains_v<PrimExpr, prim::SelectNode> = true;
856template <>
857inline constexpr bool object_ref_contains_v<PrimExpr, prim::RampNode> = true;
858template <>
859inline constexpr bool object_ref_contains_v<PrimExpr, prim::BroadcastNode> = true;
860template <>
861inline constexpr bool object_ref_contains_v<PrimExpr, prim::LetNode> = true;
862template <>
863inline constexpr bool object_ref_contains_v<PrimExpr, prim::ShuffleNode> = true;
864} // namespace ffi
865} // namespace tvm
866
867#endif // TVM_IR_PRIM_EXPR_H_
Helpers for attribute objects.
Base type of all the expressions.
Definition base_expr.h:324
Constant floating point literals in the program.
Definition expr.h:215
Constant integer literals in the program.
Definition expr.h:135
Non-nullable source-location metadata.
Definition location.h:91
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition base_expr.h:447
Definition base_expr.h:161
Reference to the shared immutable unknown location.
Definition location.h:105
Managed reference to VarNode.
Definition expr.h:714
a + b
Definition expr.h:108
static constexpr const char * _type_key
Definition expr.h:111
Managed reference to AddNode.
Definition expr.h:118
TVM_TIRX_DLL Add(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Add, PrimExpr, AddNode)
Add(ffi::ObjectPtr< AddNode > node)
Definition expr.h:121
static constexpr bool _type_container_is_exact
Definition expr.h:124
TVM_DEFINE_OBJECT_REF_COW_METHOD(AddNode)
a && b
Definition expr.h:558
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("prim.And", AndNode, ExprNode)
PrimExpr b
The right operand.
Definition expr.h:566
AndNode(PrimExpr a, PrimExpr b)
Definition expr.h:560
AndNode(ffi::UnsafeInit tag)
Definition expr.h:561
static void RegisterReflection()
Definition expr.h:567
PrimExpr a
The left operand.
Definition expr.h:564
Managed reference to AndNode.
Definition expr.h:578
TVM_TIRX_DLL And(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
TVM_DEFINE_OBJECT_REF_COW_METHOD(AndNode)
static constexpr bool _type_container_is_exact
Definition expr.h:584
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(And, PrimExpr, AndNode)
And(ffi::ObjectPtr< AndNode > node)
Definition expr.h:581
Base template to implement binary ops.
Definition expr.h:89
BinaryOpNode(PrimExpr a, PrimExpr b)
Definition expr.h:91
static const constexpr int _type_child_slots
Definition expr.h:102
BinaryOpNode(ffi::UnsafeInit tag)
Definition expr.h:92
TVM_FFI_DECLARE_OBJECT_INFO_PREDEFINED_TYPE_KEY(T, ExprNode)
static void RegisterReflection()
Definition expr.h:98
PrimExpr a
The left operand.
Definition expr.h:95
PrimExpr b
The right operand.
Definition expr.h:97
static const constexpr bool _type_final
Definition expr.h:103
a & b
Definition expr.h:171
static constexpr const char * _type_key
Definition expr.h:174
Managed reference to BitwiseAndNode.
Definition expr.h:181
TVM_TIRX_DLL BitwiseAnd(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
TVM_DEFINE_OBJECT_REF_COW_METHOD(BitwiseAndNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(BitwiseAnd, PrimExpr, BitwiseAndNode)
static constexpr bool _type_container_is_exact
Definition expr.h:187
BitwiseAnd(ffi::ObjectPtr< BitwiseAndNode > node)
Definition expr.h:184
~a
Definition expr.h:649
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("prim.BitwiseNot", BitwiseNotNode, ExprNode)
PrimExpr a
The input operand.
Definition expr.h:655
BitwiseNotNode(PrimExpr a)
Definition expr.h:651
BitwiseNotNode(ffi::UnsafeInit tag)
Definition expr.h:652
static void RegisterReflection()
Definition expr.h:656
Managed reference to BitwiseNotNode.
Definition expr.h:667
TVM_TIRX_DLL BitwiseNot(PrimExpr a, Location loc=UnknownLoc())
TVM_DEFINE_OBJECT_REF_COW_METHOD(BitwiseNotNode)
static constexpr bool _type_container_is_exact
Definition expr.h:673
BitwiseNot(ffi::ObjectPtr< BitwiseNotNode > node)
Definition expr.h:670
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(BitwiseNot, PrimExpr, BitwiseNotNode)
a | b
Definition expr.h:192
static constexpr const char * _type_key
Definition expr.h:195
Managed reference to BitwiseOrNode.
Definition expr.h:202
BitwiseOr(ffi::ObjectPtr< BitwiseOrNode > node)
Definition expr.h:205
TVM_TIRX_DLL BitwiseOr(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(BitwiseOr, PrimExpr, BitwiseOrNode)
TVM_DEFINE_OBJECT_REF_COW_METHOD(BitwiseOrNode)
static constexpr bool _type_container_is_exact
Definition expr.h:208
a ^ b
Definition expr.h:213
static constexpr const char * _type_key
Definition expr.h:216
Managed reference to BitwiseXorNode.
Definition expr.h:223
static constexpr bool _type_container_is_exact
Definition expr.h:229
TVM_DEFINE_OBJECT_REF_COW_METHOD(BitwiseXorNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(BitwiseXor, PrimExpr, BitwiseXorNode)
BitwiseXor(ffi::ObjectPtr< BitwiseXorNode > node)
Definition expr.h:226
TVM_TIRX_DLL BitwiseXor(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
Cast value from one data type to another.
Definition expr.h:56
PrimExpr value
Original data type.
Definition expr.h:62
CastNode(PrimExpr value)
Definition expr.h:58
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("prim.Cast", CastNode, ExprNode)
static void RegisterReflection()
Definition expr.h:63
CastNode(ffi::UnsafeInit tag)
Definition expr.h:59
Managed reference to CastNode.
Definition expr.h:74
static constexpr bool _type_container_is_exact
Definition expr.h:80
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Cast, PrimExpr, CastNode)
TVM_DEFINE_OBJECT_REF_COW_METHOD(CastNode)
TVM_TIRX_DLL Cast(PrimType value_ty, PrimExpr value, Location loc=UnknownLoc())
Cast(ffi::ObjectPtr< CastNode > node)
Definition expr.h:77
Base template to implement comparison ops.
Definition expr.h:413
static const constexpr bool _type_final
Definition expr.h:427
PrimExpr b
The right operand.
Definition expr.h:421
PrimExpr a
The left operand.
Definition expr.h:419
TVM_FFI_DECLARE_OBJECT_INFO_PREDEFINED_TYPE_KEY(T, ExprNode)
static void RegisterReflection()
Definition expr.h:422
CmpOpNode(PrimExpr a, PrimExpr b)
Definition expr.h:415
CmpOpNode(ffi::UnsafeInit tag)
Definition expr.h:416
static const constexpr int _type_child_slots
Definition expr.h:426
a / b in the C semnatics.
Definition expr.h:280
static constexpr const char * _type_key
Definition expr.h:283
Managed reference to DivNode.
Definition expr.h:290
Div(ffi::ObjectPtr< DivNode > node)
Definition expr.h:293
TVM_TIRX_DLL Div(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
TVM_DEFINE_OBJECT_REF_COW_METHOD(DivNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Div, PrimExpr, DivNode)
static constexpr bool _type_container_is_exact
Definition expr.h:296
a == b
Definition expr.h:432
static constexpr const char * _type_key
Definition expr.h:435
Managed reference to EQNode.
Definition expr.h:442
TVM_TIRX_DLL EQ(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(EQ, PrimExpr, EQNode)
EQ(ffi::ObjectPtr< EQNode > node)
Definition expr.h:445
static constexpr bool _type_container_is_exact
Definition expr.h:448
TVM_DEFINE_OBJECT_REF_COW_METHOD(EQNode)
Floor division, floor(a/b)
Definition expr.h:325
static constexpr const char * _type_key
Definition expr.h:328
Managed reference to FloorDivNode.
Definition expr.h:335
FloorDiv(ffi::ObjectPtr< FloorDivNode > node)
Definition expr.h:338
static constexpr bool _type_container_is_exact
Definition expr.h:341
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(FloorDiv, PrimExpr, FloorDivNode)
TVM_DEFINE_OBJECT_REF_COW_METHOD(FloorDivNode)
TVM_TIRX_DLL FloorDiv(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
The remainder of the floordiv.
Definition expr.h:346
static constexpr const char * _type_key
Definition expr.h:349
Managed reference to FloorModNode.
Definition expr.h:356
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(FloorMod, PrimExpr, FloorModNode)
TVM_TIRX_DLL FloorMod(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
FloorMod(ffi::ObjectPtr< FloorModNode > node)
Definition expr.h:359
static constexpr bool _type_container_is_exact
Definition expr.h:362
TVM_DEFINE_OBJECT_REF_COW_METHOD(FloorModNode)
a >= b
Definition expr.h:537
static constexpr const char * _type_key
Definition expr.h:540
Managed reference to GENode.
Definition expr.h:547
static constexpr bool _type_container_is_exact
Definition expr.h:553
TVM_DEFINE_OBJECT_REF_COW_METHOD(GENode)
GE(ffi::ObjectPtr< GENode > node)
Definition expr.h:550
TVM_TIRX_DLL GE(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(GE, PrimExpr, GENode)
a > b
Definition expr.h:516
static constexpr const char * _type_key
Definition expr.h:519
Managed reference to GTNode.
Definition expr.h:526
TVM_DEFINE_OBJECT_REF_COW_METHOD(GTNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(GT, PrimExpr, GTNode)
static constexpr bool _type_container_is_exact
Definition expr.h:532
TVM_TIRX_DLL GT(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
GT(ffi::ObjectPtr< GTNode > node)
Definition expr.h:529
Managed reference to LENode.
Definition expr.h:505
TVM_DEFINE_OBJECT_REF_COW_METHOD(LENode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(LE, PrimExpr, LENode)
TVM_TIRX_DLL LE(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
static constexpr bool _type_container_is_exact
Definition expr.h:511
LE(ffi::ObjectPtr< LENode > node)
Definition expr.h:508
a << b
Definition expr.h:129
static constexpr const char * _type_key
Definition expr.h:132
Managed reference to LShiftNode.
Definition expr.h:139
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(LShift, PrimExpr, LShiftNode)
TVM_DEFINE_OBJECT_REF_COW_METHOD(LShiftNode)
LShift(ffi::ObjectPtr< LShiftNode > node)
Definition expr.h:142
static constexpr bool _type_container_is_exact
Definition expr.h:145
TVM_TIRX_DLL LShift(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
a < b
Definition expr.h:474
static constexpr const char * _type_key
Definition expr.h:477
Managed reference to LTNode.
Definition expr.h:484
TVM_DEFINE_OBJECT_REF_COW_METHOD(LTNode)
LT(ffi::ObjectPtr< LTNode > node)
Definition expr.h:487
static constexpr bool _type_container_is_exact
Definition expr.h:490
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(LT, PrimExpr, LTNode)
TVM_TIRX_DLL LT(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
Let binding. Bind var to value then evaluate body.
Definition expr.h:727
PrimExpr value
The value to be binded.
Definition expr.h:736
Var var
The variable.
Definition expr.h:734
static void RegisterReflection()
Definition expr.h:739
LetNode(Var var, PrimExpr value, PrimExpr body)
Definition expr.h:729
LetNode(ffi::UnsafeInit tag)
Definition expr.h:731
PrimExpr body
The result expression.
Definition expr.h:738
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("prim.Let", LetNode, ExprNode)
Managed reference to LetNode.
Definition expr.h:753
Let(ffi::ObjectPtr< LetNode > node)
Definition expr.h:756
TVM_DEFINE_OBJECT_REF_COW_METHOD(LetNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Let, PrimExpr, LetNode)
static constexpr bool _type_container_is_exact
Definition expr.h:759
TVM_TIRX_DLL Let(Var var, PrimExpr value, PrimExpr body, Location loc=UnknownLoc())
max(a, b)
Definition expr.h:388
static constexpr const char * _type_key
Definition expr.h:391
Managed reference to MaxNode.
Definition expr.h:398
TVM_TIRX_DLL Max(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
Max(ffi::ObjectPtr< MaxNode > node)
Definition expr.h:401
TVM_DEFINE_OBJECT_REF_COW_METHOD(MaxNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Max, PrimExpr, MaxNode)
static constexpr bool _type_container_is_exact
Definition expr.h:404
min(a, b)
Definition expr.h:367
static constexpr const char * _type_key
Definition expr.h:370
Managed reference to MinNode.
Definition expr.h:377
Min(ffi::ObjectPtr< MinNode > node)
Definition expr.h:380
static constexpr bool _type_container_is_exact
Definition expr.h:383
TVM_DEFINE_OBJECT_REF_COW_METHOD(MinNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Min, PrimExpr, MinNode)
TVM_TIRX_DLL Min(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
a % b in the C semnatics.
Definition expr.h:304
static constexpr const char * _type_key
Definition expr.h:307
Managed reference to ModNode.
Definition expr.h:314
TVM_TIRX_DLL Mod(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
static constexpr bool _type_container_is_exact
Definition expr.h:320
Mod(ffi::ObjectPtr< ModNode > node)
Definition expr.h:317
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Mod, PrimExpr, ModNode)
TVM_DEFINE_OBJECT_REF_COW_METHOD(ModNode)
a * b
Definition expr.h:256
static constexpr const char * _type_key
Definition expr.h:259
Managed reference to MulNode.
Definition expr.h:266
Mul(ffi::ObjectPtr< MulNode > node)
Definition expr.h:269
TVM_TIRX_DLL Mul(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
TVM_DEFINE_OBJECT_REF_COW_METHOD(MulNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Mul, PrimExpr, MulNode)
static constexpr bool _type_container_is_exact
Definition expr.h:272
a != b
Definition expr.h:453
static constexpr const char * _type_key
Definition expr.h:456
Managed reference to NENode.
Definition expr.h:463
TVM_DEFINE_OBJECT_REF_COW_METHOD(NENode)
NE(ffi::ObjectPtr< NENode > node)
Definition expr.h:466
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(NE, PrimExpr, NENode)
TVM_TIRX_DLL NE(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
static constexpr bool _type_container_is_exact
Definition expr.h:469
!a
Definition expr.h:620
static void RegisterReflection()
Definition expr.h:627
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("prim.Not", NotNode, ExprNode)
NotNode(ffi::UnsafeInit tag)
Definition expr.h:623
PrimExpr a
The input operand.
Definition expr.h:626
NotNode(PrimExpr a)
Definition expr.h:622
Managed reference to NotNode.
Definition expr.h:638
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Not, PrimExpr, NotNode)
static constexpr bool _type_container_is_exact
Definition expr.h:644
TVM_TIRX_DLL Not(PrimExpr a, Location loc=UnknownLoc())
TVM_DEFINE_OBJECT_REF_COW_METHOD(NotNode)
Not(ffi::ObjectPtr< NotNode > node)
Definition expr.h:641
a || b
Definition expr.h:589
PrimExpr b
The right operand.
Definition expr.h:597
OrNode(ffi::UnsafeInit tag)
Definition expr.h:592
OrNode(PrimExpr a, PrimExpr b)
Definition expr.h:591
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("prim.Or", OrNode, ExprNode)
static void RegisterReflection()
Definition expr.h:598
PrimExpr a
The left operand.
Definition expr.h:595
Managed reference to OrNode.
Definition expr.h:609
TVM_DEFINE_OBJECT_REF_COW_METHOD(OrNode)
TVM_TIRX_DLL Or(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Or, PrimExpr, OrNode)
static constexpr bool _type_container_is_exact
Definition expr.h:615
Or(ffi::ObjectPtr< OrNode > node)
Definition expr.h:612
a >> b
Definition expr.h:150
static constexpr const char * _type_key
Definition expr.h:153
Managed reference to RShiftNode.
Definition expr.h:160
static constexpr bool _type_container_is_exact
Definition expr.h:166
TVM_DEFINE_OBJECT_REF_COW_METHOD(RShiftNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(RShift, PrimExpr, RShiftNode)
RShift(ffi::ObjectPtr< RShiftNode > node)
Definition expr.h:163
TVM_TIRX_DLL RShift(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
return true_value if condition is true, otherwise return false_value.
Definition expr.h:684
PrimExpr false_value
value to be returned when condition is false.
Definition expr.h:697
PrimExpr true_value
value to be returned when condition is true.
Definition expr.h:695
SelectNode(PrimExpr condition, PrimExpr true_value, PrimExpr false_value)
Definition expr.h:686
PrimExpr condition
The condition.
Definition expr.h:693
SelectNode(ffi::UnsafeInit tag)
Definition expr.h:690
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("prim.Select", SelectNode, ExprNode)
static void RegisterReflection()
Definition expr.h:698
Managed reference to SelectNode.
Definition expr.h:712
static constexpr bool _type_container_is_exact
Definition expr.h:720
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Select, PrimExpr, SelectNode)
TVM_DEFINE_OBJECT_REF_COW_METHOD(SelectNode)
TVM_TIRX_DLL Select(PrimExpr condition, PrimExpr true_value, PrimExpr false_value, Location loc=UnknownLoc())
Select(ffi::ObjectPtr< SelectNode > node)
Definition expr.h:717
a - b
Definition expr.h:234
static constexpr const char * _type_key
Definition expr.h:237
Managed reference to SubNode.
Definition expr.h:244
TVM_TIRX_DLL Sub(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
TVM_DEFINE_OBJECT_REF_COW_METHOD(SubNode)
static constexpr bool _type_container_is_exact
Definition expr.h:251
Sub(ffi::ObjectPtr< SubNode > node)
Definition expr.h:248
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Sub, PrimExpr, SubNode)
Copy-on-write helper macro for IR ffi::ObjectRef types.
Base expr nodes in TVM.
std::unordered_map< K, V > as_unordered_map(const ffi::Map< K, V > &dmap)
Definition expr.h:772
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition attr.h:23
Native object dispatch, visiting and mutation with structural fallback.
#define TVM_TIRX_DLL
Definition base.h:83
Compare two expressions recursively and check if they are equal to each other without var remapping.
Definition expr.h:795
TVM_TIRX_DLL bool operator()(const PrimExpr &lhs, const PrimExpr &rhs) const
a <= b
Definition expr.h:495
static constexpr const char * _type_key
Definition expr.h:498
Primitive vector expressions.