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 CastObj : public ExprObj {
57 public:
58 explicit CastObj(PrimExpr value) : value(std::move(value)) {}
59 explicit CastObj(ffi::UnsafeInit tag) : value(tag) {}
60
63 static void RegisterReflection() {
64 namespace refl = tvm::ffi::reflection;
65 refl::ObjectDef<CastObj>().def_ro("value", &CastObj::value);
66 }
68};
69
74class Cast : public PrimExpr {
75 public:
77 explicit Cast(ffi::ObjectPtr<CastObj> node) : PrimExpr(std::move(node)) {}
78
80 static constexpr bool _type_container_is_exact = true;
82};
83
88template <typename T>
89class BinaryOpObj : public ExprObj {
90 public:
91 BinaryOpObj(PrimExpr a, PrimExpr b) : a(std::move(a)), b(std::move(b)) {}
92 explicit BinaryOpObj(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 AddObj : public BinaryOpObj<AddObj> {
109 public:
110 using BinaryOpObj<AddObj>::BinaryOpObj;
111 static constexpr const char* _type_key = "prim.Add";
112};
113
118class Add : public PrimExpr {
119 public:
121 explicit Add(ffi::ObjectPtr<AddObj> node) : PrimExpr(std::move(node)) {}
122
124 static constexpr bool _type_container_is_exact = true;
126};
127
129class LShiftObj : public BinaryOpObj<LShiftObj> {
130 public:
131 using BinaryOpObj<LShiftObj>::BinaryOpObj;
132 static constexpr const char* _type_key = "prim.LShift";
133};
134
139class LShift : public PrimExpr {
140 public:
142 explicit LShift(ffi::ObjectPtr<LShiftObj> node) : PrimExpr(std::move(node)) {}
143
145 static constexpr bool _type_container_is_exact = true;
147};
148
150class RShiftObj : public BinaryOpObj<RShiftObj> {
151 public:
152 using BinaryOpObj<RShiftObj>::BinaryOpObj;
153 static constexpr const char* _type_key = "prim.RShift";
154};
155
160class RShift : public PrimExpr {
161 public:
163 explicit RShift(ffi::ObjectPtr<RShiftObj> node) : PrimExpr(std::move(node)) {}
164
166 static constexpr bool _type_container_is_exact = true;
168};
169
171class BitwiseAndObj : public BinaryOpObj<BitwiseAndObj> {
172 public:
173 using BinaryOpObj<BitwiseAndObj>::BinaryOpObj;
174 static constexpr const char* _type_key = "prim.BitwiseAnd";
175};
176
181class BitwiseAnd : public PrimExpr {
182 public:
184 explicit BitwiseAnd(ffi::ObjectPtr<BitwiseAndObj> node) : PrimExpr(std::move(node)) {}
185
187 static constexpr bool _type_container_is_exact = true;
189};
190
192class BitwiseOrObj : public BinaryOpObj<BitwiseOrObj> {
193 public:
194 using BinaryOpObj<BitwiseOrObj>::BinaryOpObj;
195 static constexpr const char* _type_key = "prim.BitwiseOr";
196};
197
202class BitwiseOr : public PrimExpr {
203 public:
205 explicit BitwiseOr(ffi::ObjectPtr<BitwiseOrObj> node) : PrimExpr(std::move(node)) {}
206
208 static constexpr bool _type_container_is_exact = true;
210};
211
213class BitwiseXorObj : public BinaryOpObj<BitwiseXorObj> {
214 public:
215 using BinaryOpObj<BitwiseXorObj>::BinaryOpObj;
216 static constexpr const char* _type_key = "prim.BitwiseXor";
217};
218
223class BitwiseXor : public PrimExpr {
224 public:
226 explicit BitwiseXor(ffi::ObjectPtr<BitwiseXorObj> node) : PrimExpr(std::move(node)) {}
227
229 static constexpr bool _type_container_is_exact = true;
231};
232
234class SubObj : public BinaryOpObj<SubObj> {
235 public:
236 using BinaryOpObj<SubObj>::BinaryOpObj;
237 static constexpr const char* _type_key = "prim.Sub";
238};
239
244class Sub : public PrimExpr {
245 public:
247
248 explicit Sub(ffi::ObjectPtr<SubObj> node) : PrimExpr(std::move(node)) {}
249
251 static constexpr bool _type_container_is_exact = true;
253};
254
256class MulObj : public BinaryOpObj<MulObj> {
257 public:
258 using BinaryOpObj<MulObj>::BinaryOpObj;
259 static constexpr const char* _type_key = "prim.Mul";
260};
261
266class Mul : public PrimExpr {
267 public:
269 explicit Mul(ffi::ObjectPtr<MulObj> node) : PrimExpr(std::move(node)) {}
270
272 static constexpr bool _type_container_is_exact = true;
274};
275
280class DivObj : public BinaryOpObj<DivObj> {
281 public:
282 using BinaryOpObj<DivObj>::BinaryOpObj;
283 static constexpr const char* _type_key = "prim.Div";
284};
285
290class Div : public PrimExpr {
291 public:
293 explicit Div(ffi::ObjectPtr<DivObj> node) : PrimExpr(std::move(node)) {}
294
296 static constexpr bool _type_container_is_exact = true;
298};
299
304class ModObj : public BinaryOpObj<ModObj> {
305 public:
306 using BinaryOpObj<ModObj>::BinaryOpObj;
307 static constexpr const char* _type_key = "prim.Mod";
308};
309
314class Mod : public PrimExpr {
315 public:
317 explicit Mod(ffi::ObjectPtr<ModObj> node) : PrimExpr(std::move(node)) {}
318
320 static constexpr bool _type_container_is_exact = true;
322};
323
325class FloorDivObj : public BinaryOpObj<FloorDivObj> {
326 public:
327 using BinaryOpObj<FloorDivObj>::BinaryOpObj;
328 static constexpr const char* _type_key = "prim.FloorDiv";
329};
330
335class FloorDiv : public PrimExpr {
336 public:
338 explicit FloorDiv(ffi::ObjectPtr<FloorDivObj> node) : PrimExpr(std::move(node)) {}
339
341 static constexpr bool _type_container_is_exact = true;
343};
344
346class FloorModObj : public BinaryOpObj<FloorModObj> {
347 public:
348 using BinaryOpObj<FloorModObj>::BinaryOpObj;
349 static constexpr const char* _type_key = "prim.FloorMod";
350};
351
356class FloorMod : public PrimExpr {
357 public:
359 explicit FloorMod(ffi::ObjectPtr<FloorModObj> node) : PrimExpr(std::move(node)) {}
360
362 static constexpr bool _type_container_is_exact = true;
364};
365
367class MinObj : public BinaryOpObj<MinObj> {
368 public:
369 using BinaryOpObj<MinObj>::BinaryOpObj;
370 static constexpr const char* _type_key = "prim.Min";
371};
372
377class Min : public PrimExpr {
378 public:
380 explicit Min(ffi::ObjectPtr<MinObj> node) : PrimExpr(std::move(node)) {}
381
383 static constexpr bool _type_container_is_exact = true;
385};
386
388class MaxObj : public BinaryOpObj<MaxObj> {
389 public:
390 using BinaryOpObj<MaxObj>::BinaryOpObj;
391 static constexpr const char* _type_key = "prim.Max";
392};
393
398class Max : public PrimExpr {
399 public:
401 explicit Max(ffi::ObjectPtr<MaxObj> node) : PrimExpr(std::move(node)) {}
402
404 static constexpr bool _type_container_is_exact = true;
406};
407
412template <typename T>
413class CmpOpObj : public ExprObj {
414 public:
415 CmpOpObj(PrimExpr a, PrimExpr b) : a(std::move(a)), b(std::move(b)) {}
416 explicit CmpOpObj(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 EQObj : public CmpOpObj<EQObj> {
433 public:
434 using CmpOpObj<EQObj>::CmpOpObj;
435 static constexpr const char* _type_key = "prim.EQ";
436};
437
442class EQ : public PrimExpr {
443 public:
445 explicit EQ(ffi::ObjectPtr<EQObj> node) : PrimExpr(std::move(node)) {}
446
448 static constexpr bool _type_container_is_exact = true;
450};
451
453class NEObj : public CmpOpObj<NEObj> {
454 public:
455 using CmpOpObj<NEObj>::CmpOpObj;
456 static constexpr const char* _type_key = "prim.NE";
457};
458
463class NE : public PrimExpr {
464 public:
466 explicit NE(ffi::ObjectPtr<NEObj> node) : PrimExpr(std::move(node)) {}
467
469 static constexpr bool _type_container_is_exact = true;
471};
472
474class LTObj : public CmpOpObj<LTObj> {
475 public:
476 using CmpOpObj<LTObj>::CmpOpObj;
477 static constexpr const char* _type_key = "prim.LT";
478};
479
484class LT : public PrimExpr {
485 public:
487 explicit LT(ffi::ObjectPtr<LTObj> node) : PrimExpr(std::move(node)) {}
488
490 static constexpr bool _type_container_is_exact = true;
492};
493
495struct LEObj : public CmpOpObj<LEObj> {
496 public:
497 using CmpOpObj<LEObj>::CmpOpObj;
498 static constexpr const char* _type_key = "prim.LE";
499};
500
505class LE : public PrimExpr {
506 public:
508 explicit LE(ffi::ObjectPtr<LEObj> node) : PrimExpr(std::move(node)) {}
509
511 static constexpr bool _type_container_is_exact = true;
513};
514
516class GTObj : public CmpOpObj<GTObj> {
517 public:
518 using CmpOpObj<GTObj>::CmpOpObj;
519 static constexpr const char* _type_key = "prim.GT";
520};
521
526class GT : public PrimExpr {
527 public:
529 explicit GT(ffi::ObjectPtr<GTObj> node) : PrimExpr(std::move(node)) {}
530
532 static constexpr bool _type_container_is_exact = true;
534};
535
537class GEObj : public CmpOpObj<GEObj> {
538 public:
539 using CmpOpObj<GEObj>::CmpOpObj;
540 static constexpr const char* _type_key = "prim.GE";
541};
542
547class GE : public PrimExpr {
548 public:
550 explicit GE(ffi::ObjectPtr<GEObj> node) : PrimExpr(std::move(node)) {}
551
553 static constexpr bool _type_container_is_exact = true;
555};
556
558class AndObj : public ExprObj {
559 public:
560 AndObj(PrimExpr a, PrimExpr b) : a(std::move(a)), b(std::move(b)) {}
561 explicit AndObj(ffi::UnsafeInit tag) : a(tag), b(tag) {}
562
567 static void RegisterReflection() {
568 namespace refl = tvm::ffi::reflection;
569 refl::ObjectDef<AndObj>().def_ro("a", &AndObj::a).def_ro("b", &AndObj::b);
570 }
572};
573
578class And : public PrimExpr {
579 public:
581 explicit And(ffi::ObjectPtr<AndObj> node) : PrimExpr(std::move(node)) {}
582
584 static constexpr bool _type_container_is_exact = true;
586};
587
589class OrObj : public ExprObj {
590 public:
591 OrObj(PrimExpr a, PrimExpr b) : a(std::move(a)), b(std::move(b)) {}
592 explicit OrObj(ffi::UnsafeInit tag) : a(tag), b(tag) {}
593
598 static void RegisterReflection() {
599 namespace refl = tvm::ffi::reflection;
600 refl::ObjectDef<OrObj>().def_ro("a", &OrObj::a).def_ro("b", &OrObj::b);
601 }
603};
604
609class Or : public PrimExpr {
610 public:
612 explicit Or(ffi::ObjectPtr<OrObj> node) : PrimExpr(std::move(node)) {}
613
615 static constexpr bool _type_container_is_exact = true;
617};
618
620class NotObj : public ExprObj {
621 public:
622 explicit NotObj(PrimExpr a) : a(std::move(a)) {}
623 explicit NotObj(ffi::UnsafeInit tag) : a(tag) {}
624
627 static void RegisterReflection() {
628 namespace refl = tvm::ffi::reflection;
629 refl::ObjectDef<NotObj>().def_ro("a", &NotObj::a);
630 }
632};
633
638class Not : public PrimExpr {
639 public:
641 explicit Not(ffi::ObjectPtr<NotObj> node) : PrimExpr(std::move(node)) {}
642
644 static constexpr bool _type_container_is_exact = true;
646};
647
649class BitwiseNotObj : public ExprObj {
650 public:
651 explicit BitwiseNotObj(PrimExpr a) : a(std::move(a)) {}
652 explicit BitwiseNotObj(ffi::UnsafeInit tag) : a(tag) {}
653
656 static void RegisterReflection() {
657 namespace refl = tvm::ffi::reflection;
658 refl::ObjectDef<BitwiseNotObj>().def_ro("a", &BitwiseNotObj::a);
659 }
661};
662
667class BitwiseNot : public PrimExpr {
668 public:
670 explicit BitwiseNot(ffi::ObjectPtr<BitwiseNotObj> node) : PrimExpr(std::move(node)) {}
671
673 static constexpr bool _type_container_is_exact = true;
675};
676
684class SelectObj : public ExprObj {
685 public:
690 explicit SelectObj(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<SelectObj>()
701 .def_ro("condition", &SelectObj::condition)
702 .def_ro("true_value", &SelectObj::true_value)
703 .def_ro("false_value", &SelectObj::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<SelectObj> node) : PrimExpr(std::move(node)) {}
718
720 static constexpr bool _type_container_is_exact = true;
722};
723
727class LetObj : public ExprObj {
728 public:
730 : var(std::move(var)), value(std::move(value)), body(std::move(body)) {}
731 explicit LetObj(ffi::UnsafeInit tag) : var(tag), value(tag), body(tag) {}
732
739 static void RegisterReflection() {
740 namespace refl = tvm::ffi::reflection;
741 refl::ObjectDef<LetObj>()
742 .def_ro("var", &LetObj::var, refl::AttachFieldFlag::SEqHashDefSimple())
743 .def_ro("value", &LetObj::value)
744 .def_ro("body", &LetObj::body);
745 }
747};
748
753class Let : public PrimExpr {
754 public:
756 explicit Let(ffi::ObjectPtr<LetObj> 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::CastObj> = true;
806template <>
807inline constexpr bool object_ref_contains_v<PrimExpr, prim::AddObj> = true;
808template <>
809inline constexpr bool object_ref_contains_v<PrimExpr, prim::BitwiseNotObj> = true;
810template <>
811inline constexpr bool object_ref_contains_v<PrimExpr, prim::BitwiseXorObj> = true;
812template <>
813inline constexpr bool object_ref_contains_v<PrimExpr, prim::BitwiseOrObj> = true;
814template <>
815inline constexpr bool object_ref_contains_v<PrimExpr, prim::BitwiseAndObj> = true;
816template <>
817inline constexpr bool object_ref_contains_v<PrimExpr, prim::RShiftObj> = true;
818template <>
819inline constexpr bool object_ref_contains_v<PrimExpr, prim::LShiftObj> = true;
820template <>
821inline constexpr bool object_ref_contains_v<PrimExpr, prim::SubObj> = true;
822template <>
823inline constexpr bool object_ref_contains_v<PrimExpr, prim::MulObj> = true;
824template <>
825inline constexpr bool object_ref_contains_v<PrimExpr, prim::DivObj> = true;
826template <>
827inline constexpr bool object_ref_contains_v<PrimExpr, prim::ModObj> = true;
828template <>
829inline constexpr bool object_ref_contains_v<PrimExpr, prim::FloorDivObj> = true;
830template <>
831inline constexpr bool object_ref_contains_v<PrimExpr, prim::FloorModObj> = true;
832template <>
833inline constexpr bool object_ref_contains_v<PrimExpr, prim::MinObj> = true;
834template <>
835inline constexpr bool object_ref_contains_v<PrimExpr, prim::MaxObj> = true;
836template <>
837inline constexpr bool object_ref_contains_v<PrimExpr, prim::EQObj> = true;
838template <>
839inline constexpr bool object_ref_contains_v<PrimExpr, prim::NEObj> = true;
840template <>
841inline constexpr bool object_ref_contains_v<PrimExpr, prim::LTObj> = true;
842template <>
843inline constexpr bool object_ref_contains_v<PrimExpr, prim::LEObj> = true;
844template <>
845inline constexpr bool object_ref_contains_v<PrimExpr, prim::GTObj> = true;
846template <>
847inline constexpr bool object_ref_contains_v<PrimExpr, prim::GEObj> = true;
848template <>
849inline constexpr bool object_ref_contains_v<PrimExpr, prim::AndObj> = true;
850template <>
851inline constexpr bool object_ref_contains_v<PrimExpr, prim::OrObj> = true;
852template <>
853inline constexpr bool object_ref_contains_v<PrimExpr, prim::NotObj> = true;
854template <>
855inline constexpr bool object_ref_contains_v<PrimExpr, prim::SelectObj> = true;
856template <>
857inline constexpr bool object_ref_contains_v<PrimExpr, prim::RampObj> = true;
858template <>
859inline constexpr bool object_ref_contains_v<PrimExpr, prim::BroadcastObj> = true;
860template <>
861inline constexpr bool object_ref_contains_v<PrimExpr, prim::LetObj> = true;
862template <>
863inline constexpr bool object_ref_contains_v<PrimExpr, prim::ShuffleObj> = true;
864} // namespace ffi
865} // namespace tvm
866
867#endif // TVM_IR_PRIM_EXPR_H_
Base expr nodes in TVM.
#define TVM_TIRX_DLL
Definition base.h:55
Helpers for attribute objects.
Base type of all the expressions.
Definition expr.h:66
Constant floating point literals in the program.
Definition expr.h:394
Constant integer literals in the program.
Definition expr.h:314
Non-nullable source-location metadata.
Definition location.h:91
Typed reference/view over any Expr whose ExprObj::ty is PrimType.
Definition expr.h:187
Definition type.h:182
PrimType ty() const
Definition expr.h:164
Reference to the shared immutable unknown location.
Definition location.h:105
Managed reference to VarObj.
Definition expr.h:571
a + b
Definition expr.h:108
static constexpr const char * _type_key
Definition expr.h:111
Managed reference to AddObj.
Definition expr.h:118
TVM_TIRX_DLL Add(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
TVM_DEFINE_OBJECT_REF_COW_METHOD(AddObj)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Add, PrimExpr, AddObj)
static constexpr bool _type_container_is_exact
Definition expr.h:124
Add(ffi::ObjectPtr< AddObj > node)
Definition expr.h:121
a && b
Definition expr.h:558
AndObj(PrimExpr a, PrimExpr b)
Definition expr.h:560
PrimExpr b
The right operand.
Definition expr.h:566
static void RegisterReflection()
Definition expr.h:567
AndObj(ffi::UnsafeInit tag)
Definition expr.h:561
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("prim.And", AndObj, ExprObj)
PrimExpr a
The left operand.
Definition expr.h:564
Managed reference to AndObj.
Definition expr.h:578
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(And, PrimExpr, AndObj)
TVM_TIRX_DLL And(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
And(ffi::ObjectPtr< AndObj > node)
Definition expr.h:581
static constexpr bool _type_container_is_exact
Definition expr.h:584
TVM_DEFINE_OBJECT_REF_COW_METHOD(AndObj)
Base template to implement binary ops.
Definition expr.h:89
TVM_FFI_DECLARE_OBJECT_INFO_PREDEFINED_TYPE_KEY(T, ExprObj)
static const constexpr bool _type_final
Definition expr.h:103
static const constexpr int _type_child_slots
Definition expr.h:102
static void RegisterReflection()
Definition expr.h:98
BinaryOpObj(ffi::UnsafeInit tag)
Definition expr.h:92
BinaryOpObj(PrimExpr a, PrimExpr b)
Definition expr.h:91
PrimExpr a
The left operand.
Definition expr.h:95
PrimExpr b
The right operand.
Definition expr.h:97
a & b
Definition expr.h:171
static constexpr const char * _type_key
Definition expr.h:174
Managed reference to BitwiseAndObj.
Definition expr.h:181
TVM_TIRX_DLL BitwiseAnd(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(BitwiseAnd, PrimExpr, BitwiseAndObj)
static constexpr bool _type_container_is_exact
Definition expr.h:187
TVM_DEFINE_OBJECT_REF_COW_METHOD(BitwiseAndObj)
BitwiseAnd(ffi::ObjectPtr< BitwiseAndObj > node)
Definition expr.h:184
~a
Definition expr.h:649
BitwiseNotObj(ffi::UnsafeInit tag)
Definition expr.h:652
static void RegisterReflection()
Definition expr.h:656
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("prim.BitwiseNot", BitwiseNotObj, ExprObj)
PrimExpr a
The input operand.
Definition expr.h:655
BitwiseNotObj(PrimExpr a)
Definition expr.h:651
Managed reference to BitwiseNotObj.
Definition expr.h:667
TVM_TIRX_DLL BitwiseNot(PrimExpr a, Location loc=UnknownLoc())
BitwiseNot(ffi::ObjectPtr< BitwiseNotObj > node)
Definition expr.h:670
static constexpr bool _type_container_is_exact
Definition expr.h:673
TVM_DEFINE_OBJECT_REF_COW_METHOD(BitwiseNotObj)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(BitwiseNot, PrimExpr, BitwiseNotObj)
a | b
Definition expr.h:192
static constexpr const char * _type_key
Definition expr.h:195
Managed reference to BitwiseOrObj.
Definition expr.h:202
BitwiseOr(ffi::ObjectPtr< BitwiseOrObj > 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, BitwiseOrObj)
TVM_DEFINE_OBJECT_REF_COW_METHOD(BitwiseOrObj)
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 BitwiseXorObj.
Definition expr.h:223
static constexpr bool _type_container_is_exact
Definition expr.h:229
BitwiseXor(ffi::ObjectPtr< BitwiseXorObj > node)
Definition expr.h:226
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(BitwiseXor, PrimExpr, BitwiseXorObj)
TVM_TIRX_DLL BitwiseXor(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
TVM_DEFINE_OBJECT_REF_COW_METHOD(BitwiseXorObj)
Cast value from one data type to another.
Definition expr.h:56
static void RegisterReflection()
Definition expr.h:63
CastObj(PrimExpr value)
Definition expr.h:58
PrimExpr value
Original data type.
Definition expr.h:62
CastObj(ffi::UnsafeInit tag)
Definition expr.h:59
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("prim.Cast", CastObj, ExprObj)
Managed reference to CastObj.
Definition expr.h:74
Cast(ffi::ObjectPtr< CastObj > node)
Definition expr.h:77
static constexpr bool _type_container_is_exact
Definition expr.h:80
TVM_DEFINE_OBJECT_REF_COW_METHOD(CastObj)
TVM_TIRX_DLL Cast(PrimType ty, PrimExpr value, Location loc=UnknownLoc())
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Cast, PrimExpr, CastObj)
Base template to implement comparison ops.
Definition expr.h:413
PrimExpr a
The left operand.
Definition expr.h:419
static void RegisterReflection()
Definition expr.h:422
TVM_FFI_DECLARE_OBJECT_INFO_PREDEFINED_TYPE_KEY(T, ExprObj)
CmpOpObj(PrimExpr a, PrimExpr b)
Definition expr.h:415
static const constexpr bool _type_final
Definition expr.h:427
static const constexpr int _type_child_slots
Definition expr.h:426
CmpOpObj(ffi::UnsafeInit tag)
Definition expr.h:416
PrimExpr b
The right operand.
Definition expr.h:421
a / b in the C semnatics.
Definition expr.h:280
static constexpr const char * _type_key
Definition expr.h:283
Managed reference to DivObj.
Definition expr.h:290
Div(ffi::ObjectPtr< DivObj > node)
Definition expr.h:293
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Div, PrimExpr, DivObj)
TVM_TIRX_DLL Div(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
TVM_DEFINE_OBJECT_REF_COW_METHOD(DivObj)
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 EQObj.
Definition expr.h:442
TVM_TIRX_DLL EQ(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
EQ(ffi::ObjectPtr< EQObj > node)
Definition expr.h:445
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(EQ, PrimExpr, EQObj)
static constexpr bool _type_container_is_exact
Definition expr.h:448
TVM_DEFINE_OBJECT_REF_COW_METHOD(EQObj)
Floor division, floor(a/b)
Definition expr.h:325
static constexpr const char * _type_key
Definition expr.h:328
Managed reference to FloorDivObj.
Definition expr.h:335
static constexpr bool _type_container_is_exact
Definition expr.h:341
TVM_DEFINE_OBJECT_REF_COW_METHOD(FloorDivObj)
FloorDiv(ffi::ObjectPtr< FloorDivObj > node)
Definition expr.h:338
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(FloorDiv, PrimExpr, FloorDivObj)
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 FloorModObj.
Definition expr.h:356
FloorMod(ffi::ObjectPtr< FloorModObj > node)
Definition expr.h:359
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(FloorMod, PrimExpr, FloorModObj)
TVM_TIRX_DLL FloorMod(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
static constexpr bool _type_container_is_exact
Definition expr.h:362
TVM_DEFINE_OBJECT_REF_COW_METHOD(FloorModObj)
a >= b
Definition expr.h:537
static constexpr const char * _type_key
Definition expr.h:540
Managed reference to GEObj.
Definition expr.h:547
GE(ffi::ObjectPtr< GEObj > node)
Definition expr.h:550
static constexpr bool _type_container_is_exact
Definition expr.h:553
TVM_DEFINE_OBJECT_REF_COW_METHOD(GEObj)
TVM_TIRX_DLL GE(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(GE, PrimExpr, GEObj)
a > b
Definition expr.h:516
static constexpr const char * _type_key
Definition expr.h:519
Managed reference to GTObj.
Definition expr.h:526
GT(ffi::ObjectPtr< GTObj > node)
Definition expr.h:529
static constexpr bool _type_container_is_exact
Definition expr.h:532
TVM_TIRX_DLL GT(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
TVM_DEFINE_OBJECT_REF_COW_METHOD(GTObj)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(GT, PrimExpr, GTObj)
Managed reference to LEObj.
Definition expr.h:505
LE(ffi::ObjectPtr< LEObj > node)
Definition expr.h:508
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(LE, PrimExpr, LEObj)
TVM_TIRX_DLL LE(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
static constexpr bool _type_container_is_exact
Definition expr.h:511
TVM_DEFINE_OBJECT_REF_COW_METHOD(LEObj)
a << b
Definition expr.h:129
static constexpr const char * _type_key
Definition expr.h:132
Managed reference to LShiftObj.
Definition expr.h:139
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(LShift, PrimExpr, LShiftObj)
LShift(ffi::ObjectPtr< LShiftObj > node)
Definition expr.h:142
TVM_DEFINE_OBJECT_REF_COW_METHOD(LShiftObj)
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 LTObj.
Definition expr.h:484
TVM_DEFINE_OBJECT_REF_COW_METHOD(LTObj)
static constexpr bool _type_container_is_exact
Definition expr.h:490
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(LT, PrimExpr, LTObj)
LT(ffi::ObjectPtr< LTObj > node)
Definition expr.h:487
TVM_TIRX_DLL LT(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
Let binding. Bind var to value then evaluate body.
Definition expr.h:727
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("prim.Let", LetObj, ExprObj)
PrimExpr body
The result expression.
Definition expr.h:738
LetObj(ffi::UnsafeInit tag)
Definition expr.h:731
LetObj(Var var, PrimExpr value, PrimExpr body)
Definition expr.h:729
Var var
The variable.
Definition expr.h:734
static void RegisterReflection()
Definition expr.h:739
PrimExpr value
The value to be binded.
Definition expr.h:736
Managed reference to LetObj.
Definition expr.h:753
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Let, PrimExpr, LetObj)
TVM_DEFINE_OBJECT_REF_COW_METHOD(LetObj)
Let(ffi::ObjectPtr< LetObj > node)
Definition expr.h:756
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 MaxObj.
Definition expr.h:398
TVM_TIRX_DLL Max(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
Max(ffi::ObjectPtr< MaxObj > node)
Definition expr.h:401
TVM_DEFINE_OBJECT_REF_COW_METHOD(MaxObj)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Max, PrimExpr, MaxObj)
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 MinObj.
Definition expr.h:377
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Min, PrimExpr, MinObj)
static constexpr bool _type_container_is_exact
Definition expr.h:383
Min(ffi::ObjectPtr< MinObj > node)
Definition expr.h:380
TVM_DEFINE_OBJECT_REF_COW_METHOD(MinObj)
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 ModObj.
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
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Mod, PrimExpr, ModObj)
Mod(ffi::ObjectPtr< ModObj > node)
Definition expr.h:317
TVM_DEFINE_OBJECT_REF_COW_METHOD(ModObj)
a * b
Definition expr.h:256
static constexpr const char * _type_key
Definition expr.h:259
Managed reference to MulObj.
Definition expr.h:266
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Mul, PrimExpr, MulObj)
TVM_TIRX_DLL Mul(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
static constexpr bool _type_container_is_exact
Definition expr.h:272
Mul(ffi::ObjectPtr< MulObj > node)
Definition expr.h:269
TVM_DEFINE_OBJECT_REF_COW_METHOD(MulObj)
a != b
Definition expr.h:453
static constexpr const char * _type_key
Definition expr.h:456
Managed reference to NEObj.
Definition expr.h:463
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(NE, PrimExpr, NEObj)
NE(ffi::ObjectPtr< NEObj > node)
Definition expr.h:466
TVM_TIRX_DLL NE(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
static constexpr bool _type_container_is_exact
Definition expr.h:469
TVM_DEFINE_OBJECT_REF_COW_METHOD(NEObj)
!a
Definition expr.h:620
static void RegisterReflection()
Definition expr.h:627
NotObj(ffi::UnsafeInit tag)
Definition expr.h:623
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("prim.Not", NotObj, ExprObj)
NotObj(PrimExpr a)
Definition expr.h:622
PrimExpr a
The input operand.
Definition expr.h:626
Managed reference to NotObj.
Definition expr.h:638
TVM_DEFINE_OBJECT_REF_COW_METHOD(NotObj)
Not(ffi::ObjectPtr< NotObj > node)
Definition expr.h:641
static constexpr bool _type_container_is_exact
Definition expr.h:644
TVM_TIRX_DLL Not(PrimExpr a, Location loc=UnknownLoc())
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Not, PrimExpr, NotObj)
a || b
Definition expr.h:589
OrObj(ffi::UnsafeInit tag)
Definition expr.h:592
static void RegisterReflection()
Definition expr.h:598
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("prim.Or", OrObj, ExprObj)
PrimExpr b
The right operand.
Definition expr.h:597
OrObj(PrimExpr a, PrimExpr b)
Definition expr.h:591
PrimExpr a
The left operand.
Definition expr.h:595
Managed reference to OrObj.
Definition expr.h:609
Or(ffi::ObjectPtr< OrObj > node)
Definition expr.h:612
TVM_DEFINE_OBJECT_REF_COW_METHOD(OrObj)
TVM_TIRX_DLL Or(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Or, PrimExpr, OrObj)
static constexpr bool _type_container_is_exact
Definition expr.h:615
a >> b
Definition expr.h:150
static constexpr const char * _type_key
Definition expr.h:153
Managed reference to RShiftObj.
Definition expr.h:160
static constexpr bool _type_container_is_exact
Definition expr.h:166
TVM_DEFINE_OBJECT_REF_COW_METHOD(RShiftObj)
RShift(ffi::ObjectPtr< RShiftObj > node)
Definition expr.h:163
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(RShift, PrimExpr, RShiftObj)
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
SelectObj(ffi::UnsafeInit tag)
Definition expr.h:690
PrimExpr false_value
value to be returned when condition is false.
Definition expr.h:697
SelectObj(PrimExpr condition, PrimExpr true_value, PrimExpr false_value)
Definition expr.h:686
PrimExpr condition
The condition.
Definition expr.h:693
PrimExpr true_value
value to be returned when condition is true.
Definition expr.h:695
static void RegisterReflection()
Definition expr.h:698
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("prim.Select", SelectObj, ExprObj)
Managed reference to SelectObj.
Definition expr.h:712
TVM_DEFINE_OBJECT_REF_COW_METHOD(SelectObj)
Select(ffi::ObjectPtr< SelectObj > node)
Definition expr.h:717
static constexpr bool _type_container_is_exact
Definition expr.h:720
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Select, PrimExpr, SelectObj)
TVM_TIRX_DLL Select(PrimExpr condition, PrimExpr true_value, PrimExpr false_value, Location loc=UnknownLoc())
a - b
Definition expr.h:234
static constexpr const char * _type_key
Definition expr.h:237
Managed reference to SubObj.
Definition expr.h:244
TVM_TIRX_DLL Sub(PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
Sub(ffi::ObjectPtr< SubObj > node)
Definition expr.h:248
static constexpr bool _type_container_is_exact
Definition expr.h:251
TVM_DEFINE_OBJECT_REF_COW_METHOD(SubObj)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Sub, PrimExpr, SubObj)
Copy-on-write helper macro for IR ffi::ObjectRef types.
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 analysis.h:41
Native object dispatch, visiting and mutation with structural fallback.
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.