tvm
Loading...
Searching...
No Matches
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/ffi/error.h>
29#include <tvm/ir/module.h>
30#include <tvm/relax/expr.h>
31
32namespace tvm {
33namespace relax {
34
48TVM_DLL Expr Bind(const Expr& expr, const tvm::ffi::Map<Var, Expr>& binds);
49
54TVM_DLL Type Bind(const Type& ty, const tvm::ffi::Map<Var, Expr>& binds);
55
73TVM_DLL tvm::ffi::Map<Var, Expr> InferSymbolicVarMap(
74 const tvm::ffi::Map<tvm::Var, relax::Expr>& binds, const arith::Analyzer& analyzer);
75
89TVM_DLL bool IsBoolType(const Type& ty, bool permit_unknown_rank = true,
90 bool permit_unknown_dtype = true);
91
107TVM_DLL bool IsLeafOrTuple(const Expr& expr);
108
121
133
138
143
144} // namespace relax
145} // namespace tvm
146
147#endif // TVM_RELAX_UTILS_H_
Algebra expression simplifications.
Managed reference to CallNode.
Definition expr.h:474
Managed reference to ExprNode.
Definition base_expr.h:335
Managed reference to TypeNode.
Definition base_expr.h:77
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:59
Managed reference to AnalyzerObj.
Definition analyzer.h:931
Definition expr.h:211
Definition expr.h:471
IRModule that holds the functions and type definitions.
Expr ToNonDataflow(const Expr &e)
Transform all dataflow structure to non-dataflow version.
Expr Bind(const Expr &expr, const tvm::ffi::Map< Var, Expr > &binds)
Bind the variables to a Relax expression. This is a helper function usually called by other pass func...
Function CopyWithNewVars(Function func)
Copy the given function. All variables that are bound inside the original function would be copied to...
tvm::ffi::Map< Var, Expr > InferSymbolicVarMap(const tvm::ffi::Map< tvm::Var, relax::Expr > &binds, const arith::Analyzer &analyzer)
Infer a binding map for symbolic variables.
bool IsBoolType(const Type &ty, bool permit_unknown_rank=true, bool permit_unknown_dtype=true)
Check if the given Type is for a boolean scalar (tensor of rank 0 with a boolean dtype).
bool IsImpureCall(const Call &call)
Check if the given Call node is an impure operation. If the callee is a general expression,...
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.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analyzer.h:40