tvm
utils.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_RELAX_UTILS_H_
25 #define TVM_RELAX_UTILS_H_
26 
27 #include <tvm/arith/analyzer.h>
28 #include <tvm/ir/module.h>
29 #include <tvm/relax/expr.h>
30 #include <tvm/runtime/logging.h>
31 
32 namespace tvm {
33 namespace relax {
34 
50 TVM_DLL Expr Bind(const Expr& expr, const tvm::Map<Var, Expr>& binds,
51  const tvm::Map<tir::Var, PrimExpr>& symbolic_var_map = {});
52 
57 TVM_DLL StructInfo Bind(const StructInfo& sinfo,
58  const tvm::Map<tir::Var, PrimExpr>& symbolic_var_map);
59 
78  const tvm::Map<relax::Var, relax::Expr>& binds, arith::Analyzer* analyzer);
79 
93 TVM_DLL bool IsBoolStructInfo(const StructInfo& sinfo, bool permit_unknown_rank = true,
94  bool permit_unknown_dtype = true);
95 
111 TVM_DLL bool IsLeafOrTuple(const Expr& expr);
112 
123 TVM_DLL bool IsImpureCall(const Call& call);
124 
136 
141 
146 
147 } // namespace relax
148 } // namespace tvm
149 
150 #endif // TVM_RELAX_UTILS_H_
Algebra expression simplifications.
Managed reference to RelayExprNode.
Definition: expr.h:442
Analyzer that contains bunch of sub-analyzers.
Definition: analyzer.h:629
Definition: expr.h:681
Definition: expr.h:190
Definition: expr.h:995
Managed reference to StructInfoNode.
Definition: expr.h:129
Map container of NodeRef->NodeRef in DSL graph. Map implements copy on write semantics,...
Definition: map.h:1271
IRModule that holds the functions and type definitions.
Expr ToNonDataflow(const Expr &e)
Transform all dataflow structure to non-dataflow version.
Function CopyWithNewVars(Function func)
Copy the given function. All variables that are bound inside the original function would be copied to...
bool IsImpureCall(const Call &call)
Check if the given Call node is an impure operation. If the callee is a general expression,...
Expr Bind(const Expr &expr, const tvm::Map< Var, Expr > &binds, const tvm::Map< tir::Var, PrimExpr > &symbolic_var_map={})
Bind the variables to a Relax expression. This is a helper function usually called by other pass func...
tvm::Map< tir::Var, PrimExpr > InferSymbolicVarMap(const tvm::Map< relax::Var, relax::Expr > &binds, arith::Analyzer *analyzer)
Infer a binding map for symbolic variables.
bool IsLeafOrTuple(const Expr &expr)
Check if the given expression is a "leaf" node or tuple node for normalization purposes.
Expr GetBoundValue(const Binding &b)
Get the value bound in the binding.
bool IsBoolStructInfo(const StructInfo &sinfo, bool permit_unknown_rank=true, bool permit_unknown_dtype=true)
Check if the given StructInfo is for a boolean scalar (tensor of rank 0 with a boolean dtype).
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36