tvm
predicate.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
23 #ifndef TVM_TIRX_PREDICATE_H_
24 #define TVM_TIRX_PREDICATE_H_
25 
26 #include <tvm/arith/analyzer.h>
27 #include <tvm/ffi/object.h>
28 #include <tvm/ir/module.h>
29 #include <tvm/tirx/exec_scope.h>
30 #include <tvm/tirx/stmt_functor.h>
31 #include <tvm/tirx/var.h>
32 namespace tvm {
33 namespace tirx {
34 
35 class PredicateNode : public ffi::Object {
36  public:
38  Array<Var> vars;
41 
43  PrimExpr Apply(const Array<PrimExpr>& indices) const;
44 
45  static void RegisterReflection() {
46  namespace refl = tvm::ffi::reflection;
47  refl::ObjectDef<PredicateNode>()
48  .def_ro("vars", &PredicateNode::vars, refl::AttachFieldFlag::SEqHashDef())
49  .def_ro("pred", &PredicateNode::pred);
50  }
51 
52  static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindTreeNode;
53  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.Predicate", PredicateNode, ffi::Object);
54 };
55 
56 class Predicate : public ffi::ObjectRef {
57  public:
58  explicit Predicate(Array<Var> vars, PrimExpr pred);
59 
61 };
62 
63 } // namespace tirx
64 } // namespace tvm
65 
66 #endif // TVM_TIRX_PREDICATE_H_
Algebra expression simplifications.
Reference to PrimExprNode.
Definition: expr.h:126
Definition: predicate.h:35
PrimExpr pred
The predicate.
Definition: predicate.h:40
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition: predicate.h:52
PrimExpr Apply(const Array< PrimExpr > &indices) const
Replace the variables in the predicate with the given indices.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.Predicate", PredicateNode, ffi::Object)
static void RegisterReflection()
Definition: predicate.h:45
Array< Var > vars
The variables in the predicate.
Definition: predicate.h:38
Definition: predicate.h:56
Predicate(Array< Var > vars, PrimExpr pred)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(Predicate, ffi::ObjectRef, PredicateNode)
IRModule that holds the functions and type definitions.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition: analyzer.h:37
Functors for tirx stmts utility functions to call common functors.
Variables in the TIR.