tvm
|
Relay: a high level functional IR for TVM. More...
Namespaces | |
attr | |
namespace of the attributes that can be attached to a relay::Function. | |
legalize | |
qnn | |
transform | |
Classes | |
class | PatternNode |
Base type for declaring relay pattern. More... | |
class | Pattern |
Pattern is the base type for an ADT match pattern in Relay. More... | |
class | PatternWildcardNode |
PatternWildcard container node. More... | |
class | PatternWildcard |
class | PatternVarNode |
PatternVar container node. More... | |
class | PatternVar |
class | PatternConstructorNode |
PatternVar container node. More... | |
class | PatternConstructor |
class | PatternTupleNode |
PatternVar container node. More... | |
class | PatternTuple |
class | ClauseNode |
Clause container node. More... | |
class | Clause |
class | MatchNode |
Match container node. More... | |
class | Match |
struct | ArgsortAttrs |
Attributes used in argsort operators. More... | |
struct | TopKAttrs |
struct | SearchSortedAttrs |
struct | CastHintAttrs |
Annotate an expression to be cast into specific data type. More... | |
struct | CompilerAttrs |
Options for the operators used to annotate a compiler. More... | |
struct | BitPackAttrs |
Attributes used in bitpack operators. More... | |
struct | BinaryConv2DAttrs |
Attribues used in bitserial convolution operators. More... | |
struct | BinaryDenseAttrs |
struct | CallLoweredAttrs |
Metadata for calls to TIR functions, useful for program analysis crossing Relay and TIR. More... | |
struct | DebugAttrs |
Options for the debug operators. More... | |
struct | DeviceCopyAttrs |
Options for the device copy operators. More... | |
struct | Resize1DAttrs |
Attributes used in image resize1d operator. More... | |
struct | Resize2DAttrs |
Attributes used in image resize2d operator. More... | |
struct | Resize3DAttrs |
Attributes used in image resize3d operator. More... | |
struct | CropAndResizeAttrs |
Attributes used in image crop_and_resize operator. More... | |
struct | Dilation2DAttrs |
Attributes used in dilation operators. More... | |
struct | AffineGridAttrs |
Attributes used in image affine_grid operator. More... | |
struct | GridSampleAttrs |
Attributes used in image grid_sample operator. More... | |
struct | AllocStorageAttrs |
Options for allocating storage. More... | |
struct | AllocTensorAttrs |
Options for allocating tensors. More... | |
struct | BiasAddAttrs |
Add a 1D Tensor to an axis of a data. More... | |
struct | Conv1DAttrs |
Attributes used in 1D convolution operators. More... | |
struct | Conv2DAttrs |
Attributes used in convolution operators. More... | |
struct | ConvWinogradWeightTransformAttrs |
Attributes used in winograd weight transformation operators. More... | |
struct | ConvGemmWeightTransformAttrs |
Attributes used in gemm weight transformation operators. More... | |
struct | Conv2DWinogradAttrs |
Attributes used in convolution operators with winograd algorithm. More... | |
struct | Conv2DWinogradNNPACKWeightTransformAttrs |
Attributes used in winograd weight transformation operators. More... | |
struct | Conv3DAttrs |
Attributes used in convolution operators. More... | |
struct | Conv3DTransposeAttrs |
Attributes used in transposed convolution operator. More... | |
struct | Conv3DWinogradAttrs |
Attributes used in 3d winograd convolution operators. More... | |
struct | SoftmaxAttrs |
Attributes used in softmax operators. More... | |
struct | Conv2DTransposeAttrs |
Attributes used in transposed convolution operator. More... | |
struct | DilateAttrs |
Attributes used in dilate operator. More... | |
struct | Conv1DTransposeAttrs |
Attributes used in 1D transposed convolution operator. More... | |
struct | MaxPool2DAttrs |
Attributes for max pool operator. More... | |
struct | AvgPool2DAttrs |
Attributes for avg pool operator. More... | |
struct | GlobalPool2DAttrs |
Attributes for global pool operator. More... | |
struct | AdaptivePool1DAttrs |
Attributes for 1d adaptive pool operator. More... | |
struct | AdaptivePool2DAttrs |
Attributes for 2d adaptive pool operator. More... | |
struct | AdaptivePool3DAttrs |
Attributes for 3d adaptive pool operator. More... | |
struct | MaxPool1DAttrs |
Attributes for 1D max pool operator. More... | |
struct | AvgPool1DAttrs |
Attributes for 1D avg pool operator. More... | |
struct | MaxPool3DAttrs |
Attributes for 3D max pool operator. More... | |
struct | AvgPool3DAttrs |
Attributes for 3D avg pool operator. More... | |
struct | MatmulAttrs |
Attributes for matmul operator. More... | |
struct | DenseAttrs |
Attributes for dense operator. More... | |
struct | DensePackAttrs |
Attributes for dense_pack operator. More... | |
struct | BatchMatmulAttrs |
Attributes for batch matmul operator. More... | |
struct | SparseDenseAttrs |
Attributes for sparse_dense operator. More... | |
struct | SparseTransposeAttrs |
Attributes for sparse_transpose operator. More... | |
struct | SparseConv2DAttrs |
Attributes for sparse_dense operator. More... | |
struct | FIFOBufferAttrs |
Attributes for FIFO buffer operator. More... | |
struct | UpSamplingAttrs |
Attributes for upsampling operator. More... | |
struct | UpSampling3DAttrs |
Attributes for upsampling3d operator. More... | |
struct | PadAttrs |
Attributes used for the padding operator. More... | |
struct | MirrorPadAttrs |
Attributes used for the MirrorPadding operator. More... | |
struct | LeakyReluAttrs |
Attributes for leaky relu operator. More... | |
struct | PReluAttrs |
Attributes for prelu operator. More... | |
struct | DropoutAttrs |
Attributes used in dropout operator. More... | |
struct | BatchNormAttrs |
Attributes used in batch_norm operator. More... | |
struct | InstanceNormAttrs |
Attributes used in instance_norm operator. More... | |
struct | LayerNormAttrs |
Attributes used in layer_norm operator. More... | |
struct | GroupNormAttrs |
Attributes used in group_norm operator. More... | |
struct | LRNAttrs |
Attributes for LRN operator. More... | |
struct | L2NormalizeAttrs |
Attributes for L2Normalize operator. More... | |
struct | DeformableConv2DAttrs |
Attributes for DeformableConv2D operator. More... | |
struct | SubPixelAttrs |
Attributes used in subpixel operators. More... | |
struct | CorrelationAttrs |
Attributes used in correlation operators. More... | |
struct | SpaceToBatchNDAttrs |
Attributes used in SpaceToBatchND operator. More... | |
struct | BatchToSpaceNDAttrs |
Attributes used in BatchToSpaceND operator. More... | |
struct | NLLLossAttrs |
Attributes used in NLLLoss operator. More... | |
struct | OnDeviceAttrs |
Attributes for the "on_device" annotation (ie operator). More... | |
struct | ThreefryGenerateAttrs |
struct | UniformAttrs |
struct | NormalAttrs |
struct | MultinomialAttrs |
struct | ReduceAttrs |
Attributes for Reduce operators. More... | |
struct | ArgReduceAttrs |
Attributes for Reduce operators which reduce by finding a single element. E.g. argmin. More... | |
struct | VarianceAttrs |
struct | SlidingWindowAttrs |
Attributes used for the sliding_window operator. More... | |
struct | CastAttrs |
data type cast More... | |
struct | ExpandDimsAttrs |
Attributes used in expand_dims operators. More... | |
struct | DynExpandDimsAttrs |
Attributes used in dynamic expand_dims operators. More... | |
struct | ConcatenateAttrs |
Attributes used in concatenate operators. More... | |
struct | TransposeAttrs |
Attributes used in transpose operators. More... | |
struct | ReshapeAttrs |
Attributes used in reshape operators. More... | |
struct | ReshapeLikeAttrs |
Attributes used in MXNet-style reshape_like operators. More... | |
struct | ScatterElementsAttrs |
struct | ScatterNDAttrs |
struct | GatherAttrs |
struct | GatherNDAttrs |
struct | TakeAttrs |
struct | InitOpAttrs |
Attributes that specify a tensor. More... | |
struct | ArangeAttrs |
Attributes used in arange operators. More... | |
struct | MeshgridAttrs |
Attributes used in meshgrid operators. More... | |
struct | StackAttrs |
Attributes used in stack operators. More... | |
struct | RepeatAttrs |
Attributes used in repeat operators. More... | |
struct | TileAttrs |
Attributes used in tile operators. More... | |
struct | ReverseAttrs |
Attributes used in reverse operators. More... | |
struct | ReverseSequenceAttrs |
Attributes used in reverse_sequence operators. More... | |
struct | SqueezeAttrs |
Attributes used in squeeze operators. More... | |
struct | SplitAttrs |
struct | StridedSliceAttrs |
Attributes for StridedSlice operator. More... | |
struct | SliceLikeAttrs |
struct | ClipAttrs |
Attributes for Clip operator. More... | |
struct | FixedPointMultiplyAttrs |
Attributes for FixedPointMultiply operator. More... | |
struct | FixedPointMultiplyPerAxisAttrs |
Attributes for per channel/per axes FixedPointMultiply operator. More... | |
struct | LayoutTransformAttrs |
Attributes for LayoutTransform operator. More... | |
struct | AutoSchedulerLayoutTransformAttrs |
Attributes for AutoSchedulerLayoutTransform operator. More... | |
struct | MetaScheduleLayoutTransformAttrs |
Attributes for MetaScheduleLayoutTransform operator. More... | |
struct | ShapeOfAttrs |
Attributes for ShapeOf operator. More... | |
struct | SequenceMaskAttrs |
struct | SparseToDenseAttrs |
Attributes used in sparse_to_dense operator. More... | |
struct | NdarraySizeAttrs |
Attributes for ndarray_size operator. More... | |
struct | OneHotAttrs |
Attributes used in one-hot operator. More... | |
struct | MatrixSetDiagAttrs |
Attributes used in matrix_set_diag operator. More... | |
struct | ScanopAttrs |
Attributes used in cumsum and cumprod operator. More... | |
struct | UniqueAttrs |
Attributes used in unique operator. More... | |
struct | EinsumAttrs |
Attributes used in einsum operator. More... | |
struct | StftAttrs |
Attributes used in stft operator. More... | |
struct | DFTAttrs |
Attributes used in DFT operator. More... | |
struct | TriluAttrs |
struct | MultiBoxPriorAttrs |
Attributes used in multibox_prior operators. More... | |
struct | MultiBoxTransformLocAttrs |
struct | GetValidCountsAttrs |
Attributes used in get_valid_counts operator. More... | |
struct | NonMaximumSuppressionAttrs |
Attributes used in non_maximum_suppression operator. More... | |
struct | AllClassNonMaximumSuppressionAttrs |
Attributes used in all_class_non_maximum_suppression operator. More... | |
struct | RegularNonMaximumSuppressionAttrs |
Attributes used in regular_non_maximum_suppression operator. More... | |
struct | ROIAlignAttrs |
Attributes used in roi_align operators. More... | |
struct | ROIPoolAttrs |
Attributes used in roi_pool operators. More... | |
struct | YoloReorgAttrs |
Attributes used in yolo reorg operators. More... | |
struct | ProposalAttrs |
Attributes used in proposal operators. More... | |
struct | ShapeFuncAttrs |
Options for the shape function operator. More... | |
struct | ReshapeTensorAttrs |
Attributes for VM reshape_tensor operator. More... | |
class | RelayNode |
This is the base node container of all relay structures. More... | |
class | IdNode |
The unique identifier of variables. More... | |
class | Id |
class | DFPatternCallbackNode |
Base type of all dataflow pattern callbacks. More... | |
class | DFPatternCallback |
Managed reference to dataflow pattern callbacks. More... | |
class | DFPatternNode |
Base type of all dataflow patterns. More... | |
class | DFPattern |
Managed reference to dataflow patterns. More... | |
class | ExprPatternNode |
Pattern for Relay Expression. More... | |
class | ExprPattern |
A pattern which matches a literal expression. More... | |
class | VarPatternNode |
Container for Var. More... | |
class | VarPattern |
class | ConstantPatternNode |
Container for Constant. More... | |
class | ConstantPattern |
class | CallPatternNode |
CallPattern container. More... | |
class | CallPattern |
class | FunctionPatternNode |
Relay Function container. More... | |
class | FunctionPattern |
Managed reference to FunctionNode. More... | |
class | LetPatternNode |
A binding of a sub-network. More... | |
class | LetPattern |
Let binding that binds a local var. More... | |
class | TuplePatternNode |
Tuple container. More... | |
class | TuplePattern |
class | TupleGetItemPatternNode |
class | IfPatternNode |
class | IfPattern |
class | TupleGetItemPattern |
class | AltPatternNode |
Pattern for Alternate Expressions. More... | |
class | AltPattern |
A pattern which matches either of two patterns. More... | |
class | WildcardPatternNode |
Wildcard Pattern. More... | |
class | WildcardPattern |
A pattern which matches anything. More... | |
class | TypePatternNode |
Pattern for Types. More... | |
class | TypePattern |
A pattern which matches a type in another pattern. More... | |
class | ShapePatternNode |
Pattern for Shapes. More... | |
class | ShapePattern |
A pattern which matches a type in another pattern. More... | |
class | DataTypePatternNode |
Pattern for Types. More... | |
class | DataTypePattern |
A pattern which matches a type in another pattern. More... | |
class | AttrPatternNode |
Pattern for Attributes. More... | |
class | AttrPattern |
A pattern which matches attributes in another pattern. More... | |
class | DominatorPatternNode |
Dominated Graph Pattern Pattern for fuzzy subgraphs where all outputs of the parent are used finally by the child, and every operation between the parent and the child matches the path. More... | |
class | DominatorPattern |
A pattern which matches a variable length dominator path. More... | |
class | DFPatternPrinter |
A printer class to print pattern. More... | |
class | DFPatternFunctor |
A dynamical functor that dispatches on in the first DFPattern argument. More... | |
class | DFPatternFunctor< R(const DFPattern &n, Args...)> |
class | DFPatternVisitor |
A simple visitor wrapper around DFPatternFunctor. Recursively visit the content. More... | |
struct | ErrorBuilder |
A wrapper around std::stringstream to build error. include/tvm/ir/type.h Can be consumed by CompileError to construct an error. More... | |
class | CompileError |
Custom Error class to be thrown during compilation. More... | |
class | ErrorReporter |
An abstraction around how errors are stored and reported. Designed to be opaque to users, so we can support a robust and simpler error reporting mode, as well as a more complex mode. More... | |
class | ExecutorNode |
Executor information. More... | |
class | Executor |
Managed reference class to ExecutorNode. More... | |
class | ExecutorRegEntry |
Helper structure to register Executors. More... | |
class | ConstantNode |
Constant tensor type. More... | |
class | Constant |
class | TupleNode |
Tuple container. More... | |
class | Tuple |
class | VarNode |
Container for Var. More... | |
class | Var |
class | CallNode |
Call container. More... | |
class | Call |
class | LetNode |
A binding of a sub-network. More... | |
class | Let |
class | IfNode |
container of If More... | |
class | If |
class | TupleGetItemNode |
class | TupleGetItem |
class | RefCreateNode |
class | RefCreate |
class | RefReadNode |
class | RefRead |
class | RefWriteNode |
class | RefWrite |
class | TempExprNode |
Base class of the temporary expression. More... | |
class | TempExpr |
class | ExprFunctor |
A dynamical functor that dispatches on in the first Expr argument. You can use this as a more powerful Visitor, since it allows you to define function signatures of Visit Function. More... | |
class | ExprFunctor< R(const Expr &n, Args...)> |
class | ExprVisitor |
A simple visitor wrapper around ExprFunctor. Recursively visit the content. More... | |
class | ExprMutator |
A wrapper around ExprFunctor which functionally updates the AST. More... | |
class | MixedModeVisitor |
A wrapper around ExprVisitor which traverses the Dataflow Normal AST. More... | |
class | MixedModeMutator |
Non-recursive DFS Graph Traversal for Custom Rewriting Passes. More... | |
class | ExprRewriter |
A non-iterating Expression Rewriter. More... | |
struct | v_info |
A struct to keep info of traversed expr in ExpandDataflow function. More... | |
class | FeatureSet |
A finite set of Feature. More... | |
class | FunctionNode |
Relay Function container. More... | |
class | Function |
Managed reference to FunctionNode. More... | |
class | InterpreterClosureObj |
The container type of Closures used by the interpreter. More... | |
class | InterpreterClosure |
class | RecClosureObj |
The container type of RecClosure. More... | |
class | RecClosure |
struct | RefValueObj |
class | RefValue |
struct | ConstructorValueObj |
class | ConstructorValue |
class | OpImplementationNode |
Operator implementation that includes compute and schedule function. More... | |
class | OpImplementation |
Operator implementation class. More... | |
class | OpSpecializationNode |
Specialized implementations for operators under certain conditions. More... | |
class | OpSpecialization |
Operator specialization class. More... | |
class | OpStrategyNode |
Operator strategy to choose implementation. More... | |
class | OpStrategy |
Operator strategy class. More... | |
class | PatternFunctor |
A dynamical functor on ADT patterns that dispatches on its first argument. You can use this as a more powerful visitor, since it allows you to define the types of further arguments to VisitPattern. More... | |
class | PatternFunctor< R(const Pattern &n, Args...)> |
class | PatternVisitor |
A simple visitor wrapper around PatternFunctor. More... | |
class | PatternMutator |
A wrapper around ExprFunctor which functionally updates the AST. More... | |
class | RuntimeNode |
Runtime information. More... | |
class | Runtime |
Managed reference class to RuntimeNode. More... | |
class | RuntimeRegEntry |
Helper structure to register Runtimes. More... | |
Typedefs | |
using | Constructor = tvm::Constructor |
using | ConstructorNode = tvm::ConstructorNode |
using | TypeData = tvm::TypeData |
using | TypeDataNode = tvm::TypeDataNode |
using | IndexExpr = ::tvm::PrimExpr |
Symbolic expression for tensor shape. More... | |
using | SourceName = tvm::SourceName |
using | Span = tvm::Span |
using | SpanNode = tvm::SpanNode |
using | Expr = tvm::RelayExpr |
using | ExprNode = tvm::RelayExprNode |
using | BaseFunc = tvm::BaseFunc |
using | BaseFuncNode = tvm::BaseFuncNode |
using | GlobalVar = tvm::GlobalVar |
using | GlobalVarNode = tvm::GlobalVarNode |
using | Op = tvm::Op |
using | OpNode = tvm::OpNode |
using | TOpPattern = int |
the operator pattern More... | |
using | TOpIsStateful = bool |
Whether operator is stateful or contain internal state. More... | |
using | TNonComputational = bool |
Mark the operator as non-computational. More... | |
using | TReshapeOp = bool |
Mark the operator as reshape op of its first input and can be turned into a nop when the first input and output shares the same piece of memory. More... | |
using | TShapeDataDependent = Array< Integer > |
Mark the operator whether output shape is data dependent. More... | |
using | FTVMCompute = runtime::TypedPackedFunc< Array< te::Tensor >(const Attrs &attrs, const Array< te::Tensor > &inputs, const Type &out_type)> |
Computation description interface. More... | |
using | FTVMSchedule = runtime::TypedPackedFunc< te::Schedule(const Attrs &attrs, const Array< te::Tensor > &outs, const Target &target)> |
Build the computation schedule for op whose root is at current op. More... | |
using | FTVMStrategy = GenericFunc |
Generate the strategy of operators. This function is a generic function and can be re-defined for different targets. More... | |
using | FTVMAlterOpLayout = runtime::TypedPackedFunc< Expr(const Attrs &attrs, const Array< Expr > &args, const Array< te::Tensor > &tinfos, const Type &out_type)> |
Alternate the layout of operators or replace the operator with other expressions. This function will be invoked in AlterOpLayout pass. More... | |
using | FTVMConvertOpLayout = runtime::TypedPackedFunc< Expr(const Attrs &attrs, const Array< Expr > &args, const Array< te::Tensor > &tinfos, const Array< String > &desired_layouts)> |
Convert the layout of operators or replace the operator with other expressions. This function will be invoked in ConvertLayout pass. More... | |
using | FTVMLegalize = runtime::TypedPackedFunc< Expr(const Attrs &attrs, const Array< Expr > &args, const Array< tvm::relay::Type > &arg_types)> |
Legalizes an expression with another expression. This function will be invoked in Legalize pass. It is a target-dependent pass. More... | |
using | FTVMAnnotateTarget = runtime::TypedPackedFunc< bool(const Expr &expr)> |
Annotates an expression to indicate if an op should be compiled using the given compiler/target. More... | |
using | FForwardRewrite = runtime::TypedPackedFunc< Expr(const Call &ref_call, const Array< Expr > &new_args, const ObjectRef &ctx)> |
Forward rewriting rule for a specific op. More... | |
using | FPrimalGradient = runtime::TypedPackedFunc< tvm::Array< Expr >(const Expr &orig_call, const Expr &output_grad)> |
Gradient for a specific op. More... | |
using | Shape = Array< IndexExpr > |
A runtime representation of shape. More... | |
using | FShapeFunc = runtime::TypedPackedFunc< Array< te::Tensor >(const Attrs &attrs, const Array< te::Tensor > &inputs, const Array< IndexExpr > &out_ndims)> |
using | MetaTable = Map< String, Array< ObjectRef > > |
using | AnyNode = tvm::tir::AnyNode |
using | Any = tvm::tir::Any |
using | Kind = TypeKind |
using | Type = tvm::Type |
using | TypeNode = tvm::TypeNode |
using | TypeVar = tvm::TypeVar |
using | TypeVarNode = tvm::TypeVarNode |
using | GlobalTypeVar = tvm::GlobalTypeVar |
using | GlobalTypeVarNode = tvm::GlobalTypeVarNode |
using | TupleType = tvm::TupleType |
using | TupleTypeNode = tvm::TupleTypeNode |
using | TypeConstraint = tvm::TypeConstraint |
using | TypeConstraintNode = tvm::TypeConstraintNode |
using | FuncType = tvm::FuncType |
using | FuncTypeNode = tvm::FuncTypeNode |
using | IncompleteType = tvm::IncompleteType |
using | IncompleteTypeNode = tvm::IncompleteTypeNode |
using | RelayRefType = tvm::RelayRefType |
using | RelayRefTypeNode = tvm::RelayRefTypeNode |
using | TensorType = tvm::TensorType |
using | TensorTypeNode = tvm::TensorTypeNode |
using | TypeCall = tvm::TypeCall |
using | TypeCallNode = tvm::TypeCallNode |
using | TypeRelation = tvm::TypeRelation |
using | TypeRelationNode = tvm::TypeRelationNode |
using | TypeRelationFn = tvm::TypeRelationFn |
using | TypeReporter = tvm::TypeReporter |
using | TypeReporterNode = tvm::TypeReporterNode |
Enumerations | |
enum | Feature : int { fVar = 0 , fGlobalVar = 1 , fConstant = 2 , fTuple = 3 , fTupleGetItem = 4 , fFunction = 5 , fOp = 6 , fCall = 7 , fLet = 8 , fIf = 9 , fRefCreate = 10 , fRefRead = 11 , fRefWrite = 12 , fConstructor = 13 , fMatch = 14 , fGraph = 15 , fLetRec = 16 } |
Different kinds of relay feature a program might use. More... | |
enum | OpPatternKind { kElemWise = 0 , kBroadcast = 1 , kInjective = 2 , kCommReduce = 3 , kOutEWiseFusable = 4 , kTuple = 7 , kOpaque = 8 } |
operator pattern used in graph fusion More... | |
enum | AnyCodegenStrategy { kVariableDimensions } |
The codegeneration strategy for dynamic dimensions. More... | |
Functions | |
Clause | WithFields (Clause clause, Optional< Pattern > opt_lhs=Optional< Pattern >(), Optional< Expr > opt_rhs=Optional< Expr >()) |
Returns clause with the given properties. A null property denotes 'no change'. Returns clause if all properties are unchanged. Otherwise, returns a copy with the new fields. More... | |
Match | WithFields (Match match, Optional< Expr > opt_data=Optional< Expr >(), Optional< Array< Clause >> opt_clauses=Optional< Array< Clause >>(), Optional< Bool > opt_complete=Optional< Bool >(), Optional< Span > opt_span=Optional< Span >()) |
Returns match with the given properties. A null property denotes 'no change'. Returns match if all properties are unchanged. Otherwise, returns a copy with the new fields. More... | |
Kind | KindCheck (const Type &t, const IRModule &mod, Optional< DiagnosticContext > diag_ctx=Optional< DiagnosticContext >()) |
Check that types are well kinded by applying "kinding rules". More... | |
bool | ConstantCheck (const Expr &e) |
Check whether an expression is constant. More... | |
bool | BasicBlockNormalFormCheck (const Expr &e) |
Check whether an expression is in the basic block normal form. More... | |
bool | WellFormed (const Expr &expr, Optional< DiagnosticContext > diag_ctx=Optional< DiagnosticContext >()) |
Check that each Var is only bound once. More... | |
tvm::Array< Var > | BoundVars (const Expr &expr) |
Get all bound variables from expression expr. More... | |
tvm::Array< Var > | BoundVars (const Pattern &pat) |
Get all bound variables from pattern pat. More... | |
tvm::Array< Var > | FreeVars (const Expr &expr) |
Get free type parameters from expression expr. More... | |
tvm::Array< Var > | AllVars (const Expr &expr) |
Get all variables from expression expr. More... | |
tvm::Array< TypeVar > | FreeTypeVars (const Expr &expr, const IRModule &mod) |
Get free TypeVars from expression expr. More... | |
tvm::Array< TypeVar > | FreeTypeVars (const Type &t, const IRModule &mod) |
Get free TypeVars from type t. More... | |
tvm::Array< TypeVar > | BoundTypeVars (const Expr &expr, const IRModule &mod) |
Get all bound type variables from expression expr. More... | |
tvm::Array< TypeVar > | BoundTypeVars (const Type &t, const IRModule &mod) |
Get all bound type variables from type t. More... | |
tvm::Array< TypeVar > | AllTypeVars (const Expr &expr, const IRModule &mod) |
Get all type variables in expression expr. More... | |
tvm::Array< TypeVar > | AllTypeVars (const Type &t, const IRModule &mod) |
Get all type variables in type t. More... | |
Array< Pattern > | UnmatchedCases (const Match &match, const IRModule &mod) |
Finds cases that the given match expression does not catch, if any. More... | |
std::unordered_map< const Object *, size_t > | GetExprRefCount (const Expr &body) |
Get reference counter of each internal ExprNode in body. More... | |
IRModule | GetCalibrateModule (IRModule mod) |
Get the updated module for collecting calibration data. More... | |
Map< GlobalVar, Array< Integer > > | GetCalibrateOutputMap (const IRModule &mod) |
Get the output map between subgrpahs and its inputs/output. More... | |
std::vector< TensorType > | FlattenTupleType (const Type &type) |
std::vector< Expr > | FromTupleType (const Type &type, const Expr &expr) |
Expr | ToTupleType (const Type &t, const std::vector< Expr > &exprs) |
String | PrettyPrint (const ObjectRef &node) |
Pretty print a node for debug purposes. More... | |
String | AsText (const ObjectRef &node, bool show_meta_data=true, runtime::TypedPackedFunc< String(ObjectRef)> annotate=nullptr) |
Render the node as a string in the text format. More... | |
bool | MatchPattern (DFPattern pattern, Expr expr) |
Determine if a pattern matches an expression. More... | |
Expr | RewritePatterns (Array< DFPatternCallback > callbacks, Expr expr, IRModule mod=IRModule()) |
Rewrite an expression based on some number of DFPatternCallbacks. More... | |
Expr | PartitionPattern (DFPattern pattern, Expr expr, Map< String, ObjectRef > attrs, PackedFunc check) |
Partition all matches of a DFPattern inside an Expr into separate Function calls. More... | |
Expr | InferType (const Expr &expr) |
Infer the type of an expression. More... | |
DFPattern | IsVar (const String &name) |
Syntatic Sugar for creating a VarPattern with a name. More... | |
DFPattern | IsConstant () |
Syntatic Sugar for creating a ConstantPattern. More... | |
DFPattern | IsWildcard () |
Syntatic Sugar for creating a WildcardPattern. More... | |
DFPattern | IsExpr (const Expr &expr) |
Syntatic Sugar for creating a ExprPattern. More... | |
DFPattern | IsOp (const String &op_name) |
Syntatic Sugar for creating a ExprPattern base on an Op. More... | |
DFPattern | IsTuple (const Array< DFPattern > &fields) |
Syntatic Sugar for creating a TuplePattern. More... | |
DFPattern | IsTupleGetItem (const DFPattern tuple, int index=-1) |
Syntatic Sugar for creating a TupleGetItemPattern. More... | |
std::ostream & | operator<< (std::ostream &os, const DFPattern &n) |
String | PrettyPrint (const DFPattern &pattern) |
Constant | WithFields (Constant constant, Optional< runtime::NDArray > opt_data={}, Optional< VirtualDevice > opt_virtual_device={}, Optional< Span > opt_span={}) |
Returns constant with the given properties. A null property denotes 'no change'. Returns constant if all properties are unchanged. Otherwise, returns a copy with the new fields. More... | |
Tuple | WithFields (Tuple tuple, Optional< Array< Expr >> opt_fields=Optional< Array< Expr >>(), Optional< VirtualDevice > opt_virtual_device=Optional< VirtualDevice >(), Optional< Span > opt_span=Optional< Span >()) |
Returns tuple with the given properties. A null property denotes 'no change'. Returns tuple if all properties are unchanged. Otherwise, returns a copy with the new fields. More... | |
Var | WithFields (Var var, Optional< Id > opt_vid=Optional< Id >(), Optional< Type > opt_type_annotation=Optional< Type >(), Optional< VirtualDevice > opt_virtual_device=Optional< VirtualDevice >(), Optional< Span > opt_span=Optional< Span >()) |
Returns var with the given properties. A null property denotes 'no change'. Returns var if all properties are unchanged. Otherwise, returns a copy with the new fields. More... | |
Call | WithFields (Call call, Optional< Expr > opt_op=Optional< Expr >(), Optional< Array< Expr >> opt_args=Optional< Array< Expr >>(), Optional< Attrs > opt_attrs=Optional< Attrs >(), Optional< Array< Type >> opt_type_args=Optional< Array< Type >>(), Optional< VirtualDevice > opt_virtual_device=Optional< VirtualDevice >(), Optional< Span > opt_span=Optional< Span >()) |
Returns call with the given properties. A null property denotes 'no change'. Returns call if all properties are unchanged. Otherwise, returns a copy with the new fields. More... | |
Let | WithFields (Let let, Optional< Var > opt_var=Optional< Var >(), Optional< Expr > opt_value=Optional< Expr >(), Optional< Expr > opt_body=Optional< Expr >(), Optional< VirtualDevice > opt_virtual_device=Optional< VirtualDevice >(), Optional< Span > opt_span=Optional< Span >()) |
Returns let with the given properties. A null property denotes 'no change'. Returns let if all properties are unchanged. Otherwise, returns a copy with the new fields. More... | |
If | WithFields (If if_expr, Optional< Expr > opt_cond=Optional< Expr >(), Optional< Expr > opt_true_branch=Optional< Expr >(), Optional< Expr > opt_false_branch=Optional< Expr >(), Optional< VirtualDevice > opt_virtual_device=Optional< VirtualDevice >(), Optional< Span > opt_span=Optional< Span >()) |
Returns if_expr with the given properties. A null property denotes 'no change'. Returns if_expr if all properties are unchanged. Otherwise, returns a copy with the new fields. More... | |
TupleGetItem | WithFields (TupleGetItem tuple_get_item, Optional< Expr > opt_tuple=Optional< Expr >(), Optional< Integer > opt_index=Optional< Integer >(), Optional< VirtualDevice > opt_virtual_device=Optional< VirtualDevice >(), Optional< Span > opt_span=Optional< Span >()) |
Returns tuple_get_item with the given properties. A null property denotes 'no change'. Returns tuple_get_item if all properties are unchanged. Otherwise, returns a copy with the new fields. More... | |
RefCreate | WithFields (RefCreate ref_create, Optional< Expr > opt_value=Optional< Expr >(), Optional< VirtualDevice > opt_virtual_device=Optional< VirtualDevice >(), Optional< Span > opt_span=Optional< Span >()) |
Returns ref_create with the given properties. A null property denotes 'no change'. Returns ref_crete if all properties are unchanged. Otherwise, returns a copy with the new fields. More... | |
RefRead | WithFields (RefRead ref_read, Optional< Expr > opt_ref=Optional< Expr >(), Optional< VirtualDevice > opt_virtual_device=Optional< VirtualDevice >(), Optional< Span > opt_span=Optional< Span >()) |
Returns ref_read with the given properties. A null property denotes 'no change'. Returns ref_read if all properties are unchanged. Otherwise, returns a copy with the new fields. More... | |
RefWrite | WithFields (RefWrite ref_write, Optional< Expr > opt_ref=Optional< Expr >(), Optional< Expr > opt_value=Optional< Expr >(), Optional< VirtualDevice > opt_virtual_device=Optional< VirtualDevice >(), Optional< Span > opt_span=Optional< Span >()) |
Returns ref_write with the given properties. A null property denotes 'no change'. Returns ref_write if all properties are unchanged. Otherwise, returns a copy with the new fields. More... | |
Expr | PostOrderRewrite (const Expr &expr, ExprRewriter *rewriter) |
Non-recursive DFS Graph Traversal for Custom Rewriting Passes. More... | |
void | PostOrderVisit (const Expr &node, std::function< void(const Expr &)> fvisit) |
recursively visit the ir in post DFS order node, apply fvisit Each node is guaranteed to be visited only once. More... | |
template<typename FCheckVisited , typename FVisitLeaf , typename FExpandExpr > | |
void | ExpandDataflow (Expr expr, FCheckVisited fcheck_visited, FVisitLeaf fvisit_leaf, FExpandExpr fexpand_expr) |
A function to iteratively traverse dataflow regions of a graph. More... | |
template<typename FCheckVisited , typename FVisitLeaf > | |
void | ExpandDataflow (Expr expr, FCheckVisited fcheck_visited, FVisitLeaf fvisit_leaf) |
void | ExpandANormalForm (const LetNode *op, std::function< void(const LetNode *)> pre_visit, std::function< void(const LetNode *)> post_visit) |
FeatureSet | DetectFeature (const RelayExpr &expr) |
Calculate the feature of the program. More... | |
FeatureSet | DetectFeature (const IRModule &mod) |
Calculate the feature of the program. More... | |
FeatureSet | DetectFeature (const Expr &expr, const IRModule &mod) |
Calculate the feature of the program. More... | |
void | CheckFeature (const RelayExpr &expr, const FeatureSet &fs) |
Check the feature of the program. More... | |
void | CheckFeature (const IRModule &mod, const FeatureSet &fs) |
Check the feature of the program. More... | |
void | CheckFeature (const RelayExpr &expr, const IRModule &mod, const FeatureSet &fs) |
Check the feature of the program. More... | |
Function | WithFields (Function function, Optional< Array< Var >> opt_params=Optional< Array< Var >>(), Optional< Expr > opt_body=Optional< Expr >(), Optional< Type > opt_ret_type=Optional< Type >(), Optional< Array< TypeVar >> opt_ty_params=Optional< Array< TypeVar >>(), Optional< DictAttrs > opt_attrs=Optional< DictAttrs >(), Optional< VirtualDevice > opt_virtual_device=Optional< VirtualDevice >(), Optional< Span > opt_span=Optional< Span >()) |
Returns function with the given properties. A null property denotes 'no change'. Returns function if all properties are unchanged. Otherwise, returns a copy with the new fields. More... | |
const FunctionNode * | AsOptimizableFunctionNode (const BaseFunc &base_func) |
TypedPackedFunc< ObjectRef(Array< Expr >)> | EvalFunction (IRModule mod, Expr expr, Device device, Target target) |
Returns a packed function over Relay expressions which will evaluate expr applied to those arguments, where expr is w.r.t. the definitions in mod . More... | |
ObjectRef | Eval (Expr expr, Map< GlobalTypeVar, TypeData > type_definitions, std::unordered_set< String > import_set, Device device, Target target, Map< String, ObjectRef > attrs={}) |
Evaluates expr and returns its result. More... | |
IRModule | ParseModule (const std::string &file_name, const std::string &file_content, const Optional< IRModule > &init_module=Optional< IRModule >(), const MetaTable &init_meta_table=MetaTable()) |
tvm::transform::Pass | AnnotateSpans () |
This pass pretty-prints mod then parses it back so as to establish spans and sources for all Relay sub-expressions. This improves error and debugging diagnostics downstream for modules constructed programaticaly rather than textually. More... | |
Expr | Bind (const Expr &expr, const tvm::Map< Var, Expr > &binds) |
Bind the free variables to a Relay expression. This is a helper function usually called by other pass functions to help optimizations. If any free variables are introduced into a function, those are added to the functoin parameters. Additionally this may change the order of parameters if you map a variable to a variable. More... | |
Function | SubstituteBoundVars (const Function &func, const tvm::Map< Var, Expr > &binds) |
Substitute variables with new variables (including function parameters) in a function. This is a helper function usually called by other pass functions to help optimizations. Expects all values in the bind map to be Vars. More... | |
Expr | ForwardRewrite (const Expr &expr, const String &rewrite_map_attr_name, std::function< ObjectRef(const Call &)> fcontext=nullptr, std::function< Expr(const Expr &)> fmulti_ref_trigger=nullptr) |
Apply rewrite rules to rewrite the expr in post DFS order. This function is used as a helper function to rewrtie an expression in a pass. More... | |
Expr | ForwardRewrite (const Expr &expr, const FForwardRewrite &rewrite_func, std::function< ObjectRef(const Call &)> fcontext=nullptr, std::function< Expr(const Expr &)> fmulti_ref_trigger=nullptr) |
Apply rewrite rules to rewrite the expr in post DFS order. This function is used as a helper function to rewrtie an expression in a pass. More... | |
Expr | RewriteAnnotatedOps (const Expr &expr, int fallback_device) |
Rewrite the annotated program. More... | |
Function | ToCPS (const Function &f, const IRModule &mod) |
Turn an expression into continuation passing style(CPS). More... | |
Function | UnCPS (const Function &f) |
Remove the continuation argument of a CPS function. More... | |
Expr | DeDup (const Expr &e) |
Deduplicate the bound variables and type variables in the expression. More... | |
Variables | |
constexpr size_t | feature_count = 17 |
Relay: a high level functional IR for TVM.
This namespace contains the abstract syntax tree, and other essential data structures for the Relay IR.
You can find more about Relay by reading the language reference.
using tvm::relay::Any = typedef tvm::tir::Any |
using tvm::relay::AnyNode = typedef tvm::tir::AnyNode |
using tvm::relay::BaseFunc = typedef tvm::BaseFunc |
using tvm::relay::BaseFuncNode = typedef tvm::BaseFuncNode |
using tvm::relay::Constructor = typedef tvm::Constructor |
using tvm::relay::ConstructorNode = typedef tvm::ConstructorNode |
using tvm::relay::Expr = typedef tvm::RelayExpr |
using tvm::relay::ExprNode = typedef tvm::RelayExprNode |
using tvm::relay::FForwardRewrite = typedef runtime::TypedPackedFunc<Expr( const Call& ref_call, const Array<Expr>& new_args, const ObjectRef& ctx)> |
Forward rewriting rule for a specific op.
ref_call | The reference old call type to be rewritten. We can make use of the op and type information. |
new_args | The new arguments (some of them could be TempExpr). |
ctx | Optional context information about ref_call. |
using tvm::relay::FPrimalGradient = typedef runtime::TypedPackedFunc<tvm::Array<Expr>(const Expr& orig_call, const Expr& output_grad)> |
Gradient for a specific op.
orig_call | the original Expr. |
output_grad | the gradient of the Expr. |
using tvm::relay::FShapeFunc = typedef runtime::TypedPackedFunc<Array<te::Tensor>( const Attrs& attrs, const Array<te::Tensor>& inputs, const Array<IndexExpr>& out_ndims)> |
using tvm::relay::FTVMAlterOpLayout = typedef runtime::TypedPackedFunc<Expr(const Attrs& attrs, const Array<Expr>& args, const Array<te::Tensor>& tinfos, const Type& out_type)> |
Alternate the layout of operators or replace the operator with other expressions. This function will be invoked in AlterOpLayout pass.
attrs | The attribute of the original node. |
args | The input symbols of the original node. |
tinfos | An array of placeholders, use for getting the inferred shape and dtype of the inputs. |
using tvm::relay::FTVMAnnotateTarget = typedef runtime::TypedPackedFunc<bool(const Expr& expr)> |
Annotates an expression to indicate if an op should be compiled using the given compiler/target.
expr | The original expr. |
using tvm::relay::FTVMCompute = typedef runtime::TypedPackedFunc<Array<te::Tensor>( const Attrs& attrs, const Array<te::Tensor>& inputs, const Type& out_type)> |
Computation description interface.
So far we restrict tuple support to the following case:
In both cases, the tuple is flattened as array.
attrs | The attribute of the primitive |
inputs | The input tensors. |
out_type | The output type information & these are always placeholders. |
using tvm::relay::FTVMConvertOpLayout = typedef runtime::TypedPackedFunc<Expr( const Attrs& attrs, const Array<Expr>& args, const Array<te::Tensor>& tinfos, const Array<String>& desired_layouts)> |
Convert the layout of operators or replace the operator with other expressions. This function will be invoked in ConvertLayout pass.
attrs | The attribute of the original node. |
inputs | The input symbols of the original node. |
tinfos | An array of placeholders, use for getting the inferred shape and dtype of the inputs. |
desired_layouts | Specify an array of desired layouts for each input. For example a conv2d op: Array("NHWC", "OHWI"), this specifies the desired layout for data then kernel. |
using tvm::relay::FTVMLegalize = typedef runtime::TypedPackedFunc<Expr(const Attrs& attrs, const Array<Expr>& args, const Array<tvm::relay::Type>& arg_types)> |
Legalizes an expression with another expression. This function will be invoked in Legalize pass. It is a target-dependent pass.
attrs | The attribute of the original node. |
args | The input symbols of the original node. |
arg_types | An array of placeholders, use for getting the inferred shape and dtype of the inputs. |
using tvm::relay::FTVMSchedule = typedef runtime::TypedPackedFunc<te::Schedule( const Attrs& attrs, const Array<te::Tensor>& outs, const Target& target)> |
Build the computation schedule for op whose root is at current op.
attrs | The attribute of the node. |
outs | The output tensors. |
target | The build target. |
using tvm::relay::FTVMStrategy = typedef GenericFunc |
Generate the strategy of operators. This function is a generic function and can be re-defined for different targets.
The function signature of generic function is: OpStrategy(const Attrs& attrs, const Array<Tensor>& inputs, const Type& out_type, const Target& target)
using tvm::relay::FuncType = typedef tvm::FuncType |
using tvm::relay::FuncTypeNode = typedef tvm::FuncTypeNode |
using tvm::relay::GlobalTypeVar = typedef tvm::GlobalTypeVar |
using tvm::relay::GlobalTypeVarNode = typedef tvm::GlobalTypeVarNode |
using tvm::relay::GlobalVar = typedef tvm::GlobalVar |
using tvm::relay::GlobalVarNode = typedef tvm::GlobalVarNode |
using tvm::relay::IncompleteType = typedef tvm::IncompleteType |
using tvm::relay::IncompleteTypeNode = typedef tvm::IncompleteTypeNode |
using tvm::relay::IndexExpr = typedef ::tvm::PrimExpr |
Symbolic expression for tensor shape.
using tvm::relay::Kind = typedef TypeKind |
using tvm::relay::MetaTable = typedef Map<String, Array<ObjectRef> > |
using tvm::relay::Op = typedef tvm::Op |
using tvm::relay::OpNode = typedef tvm::OpNode |
using tvm::relay::RelayRefType = typedef tvm::RelayRefType |
using tvm::relay::RelayRefTypeNode = typedef tvm::RelayRefTypeNode |
using tvm::relay::Shape = typedef Array<IndexExpr> |
A runtime representation of shape.
using tvm::relay::SourceName = typedef tvm::SourceName |
using tvm::relay::Span = typedef tvm::Span |
using tvm::relay::SpanNode = typedef tvm::SpanNode |
using tvm::relay::TensorType = typedef tvm::TensorType |
using tvm::relay::TensorTypeNode = typedef tvm::TensorTypeNode |
using tvm::relay::TNonComputational = typedef bool |
Mark the operator as non-computational.
using tvm::relay::TOpIsStateful = typedef bool |
Whether operator is stateful or contain internal state.
All the primitive ops we registered so far are pure. This attribute is left for potential future compatible reasons. We can always work around the stateful ops by adding an additional handle argument and return it.
using tvm::relay::TOpPattern = typedef int |
the operator pattern
using tvm::relay::TReshapeOp = typedef bool |
Mark the operator as reshape op of its first input and can be turned into a nop when the first input and output shares the same piece of memory.
using tvm::relay::TShapeDataDependent = typedef Array<Integer> |
Mark the operator whether output shape is data dependent.
using tvm::relay::TupleType = typedef tvm::TupleType |
using tvm::relay::TupleTypeNode = typedef tvm::TupleTypeNode |
using tvm::relay::Type = typedef tvm::Type |
using tvm::relay::TypeCall = typedef tvm::TypeCall |
using tvm::relay::TypeCallNode = typedef tvm::TypeCallNode |
using tvm::relay::TypeConstraint = typedef tvm::TypeConstraint |
using tvm::relay::TypeConstraintNode = typedef tvm::TypeConstraintNode |
using tvm::relay::TypeData = typedef tvm::TypeData |
using tvm::relay::TypeDataNode = typedef tvm::TypeDataNode |
using tvm::relay::TypeNode = typedef tvm::TypeNode |
using tvm::relay::TypeRelation = typedef tvm::TypeRelation |
using tvm::relay::TypeRelationFn = typedef tvm::TypeRelationFn |
using tvm::relay::TypeRelationNode = typedef tvm::TypeRelationNode |
using tvm::relay::TypeReporter = typedef tvm::TypeReporter |
using tvm::relay::TypeReporterNode = typedef tvm::TypeReporterNode |
using tvm::relay::TypeVar = typedef tvm::TypeVar |
using tvm::relay::TypeVarNode = typedef tvm::TypeVarNode |
enum tvm::relay::Feature : int |
Different kinds of relay feature a program might use.
tvm::Array<TypeVar> tvm::relay::AllTypeVars | ( | const Expr & | expr, |
const IRModule & | mod | ||
) |
Get all type variables in expression expr.
expr | the expression. |
mod | the module. |
tvm::Array<TypeVar> tvm::relay::AllTypeVars | ( | const Type & | t, |
const IRModule & | mod | ||
) |
Get all type variables in type t.
t | the type. |
mod | the module. |
tvm::Array<Var> tvm::relay::AllVars | ( | const Expr & | expr | ) |
Get all variables from expression expr.
expr | the expression. |
tvm::transform::Pass tvm::relay::AnnotateSpans | ( | ) |
This pass pretty-prints mod then parses it back so as to establish spans and sources for all Relay sub-expressions. This improves error and debugging diagnostics downstream for modules constructed programaticaly rather than textually.
const FunctionNode* tvm::relay::AsOptimizableFunctionNode | ( | const BaseFunc & | base_func | ) |
String tvm::relay::AsText | ( | const ObjectRef & | node, |
bool | show_meta_data = true , |
||
runtime::TypedPackedFunc< String(ObjectRef)> | annotate = nullptr |
||
) |
Render the node as a string in the text format.
node | The node to be rendered. |
show_meta_data | Whether to print meta data section. |
annotate | An optional callback function for attaching additional comment block to an expr. |
bool tvm::relay::BasicBlockNormalFormCheck | ( | const Expr & | e | ) |
Check whether an expression is in the basic block normal form.
e | the expression. |
Bind the free variables to a Relay expression. This is a helper function usually called by other pass functions to help optimizations. If any free variables are introduced into a function, those are added to the functoin parameters. Additionally this may change the order of parameters if you map a variable to a variable.
expr | The input expression. |
binds | The variable to expression map that will be used to help the binding. |
tvm::Array<TypeVar> tvm::relay::BoundTypeVars | ( | const Expr & | expr, |
const IRModule & | mod | ||
) |
Get all bound type variables from expression expr.
Bound variables are all type variables that are declared in the expr. They only have meaning inside that expr, and can only be used in it.
expr | the expression. |
mod | the module. |
tvm::Array<TypeVar> tvm::relay::BoundTypeVars | ( | const Type & | t, |
const IRModule & | mod | ||
) |
Get all bound type variables from type t.
Bound variables are all type variables that are declared in the type. They only have meaning inside that type, and can only be used in it.
t | the type |
mod | the module. |
tvm::Array<Var> tvm::relay::BoundVars | ( | const Expr & | expr | ) |
Get all bound variables from expression expr.
Bound variables are all variables that are declared in the expr. They only have meaning inside that expr, and can only be used in it.
expr | the expression. |
tvm::Array<Var> tvm::relay::BoundVars | ( | const Pattern & | pat | ) |
Get all bound variables from pattern pat.
Bound variables are all variables that got bound by the pat. They only have meaning inside that expr, and can only be used in it.
pat | the Pattern. |
void tvm::relay::CheckFeature | ( | const IRModule & | mod, |
const FeatureSet & | fs | ||
) |
Check the feature of the program.
mod | The module. |
fs | The feature set of the program. |
void tvm::relay::CheckFeature | ( | const RelayExpr & | expr, |
const FeatureSet & | fs | ||
) |
Check the feature of the program.
expr | The expression. |
fs | The feature set of the program. |
|
inline |
Check the feature of the program.
expr | The expression. |
mod | The module. |
fs | The feature set of the program. |
bool tvm::relay::ConstantCheck | ( | const Expr & | e | ) |
Check whether an expression is constant.
If the inputs of an expression are all constant, it means the expression itself is constant also.
e | the expression. |
Deduplicate the bound variables and type variables in the expression.
e | the expression. |
|
inline |
Calculate the feature of the program.
expr | The expression. |
mod | The module. |
FeatureSet tvm::relay::DetectFeature | ( | const IRModule & | mod | ) |
FeatureSet tvm::relay::DetectFeature | ( | const RelayExpr & | expr | ) |
ObjectRef tvm::relay::Eval | ( | Expr | expr, |
Map< GlobalTypeVar, TypeData > | type_definitions, | ||
std::unordered_set< String > | import_set, | ||
Device | device, | ||
Target | target, | ||
Map< String, ObjectRef > | attrs = {} |
||
) |
Evaluates expr
and returns its result.
This function is intended to support TVM constant evaluation.
expr | An expression to evaluate. |
type_definitions | Global type definitions which expr may references. |
import_set | Already imported external modules. |
device | The device on which all primitives will be executed. |
target | The compiler target flag for compiling primitives. |
attrs | Attributes for the expression to be evaluated with |
TypedPackedFunc<ObjectRef(Array<Expr>)> tvm::relay::EvalFunction | ( | IRModule | mod, |
Expr | expr, | ||
Device | device, | ||
Target | target | ||
) |
Returns a packed function over Relay expressions which will evaluate expr
applied to those arguments, where expr
is w.r.t. the definitions in mod
.
This function is intended to support the Python 'debug' executor.
The given expr
should have function type. The given mod
may be empty or undefined if expr
is self-contained. Relay arguments passed to the result packed function must be constants, references, or constructors/tuples over such. As much work as possible is done while constructing the result packed function, and that function may be reasonably efficiently applied multiple times without redoing unnecessary work.
Primitives are lowered and compiled to packed functions for execution on device
with properties given by target
. All other Relay constructs are interpreted.
The interpreter is intended to be a 'reference' implementation of the Relay semantics for testing and interactive use. It is not intended to be particularly efficient.
mod | A module containing definitions which can be referenced from expr . May be empty or undefined. |
expr | An expression of function type to evaluate. May reference definitions from mod . |
device | The device on which all primitives will be executed. |
target | The compiler target flag for compiling primitives. |
expr
to those arguments. void tvm::relay::ExpandANormalForm | ( | const LetNode * | op, |
std::function< void(const LetNode *)> | pre_visit, | ||
std::function< void(const LetNode *)> | post_visit | ||
) |
void tvm::relay::ExpandDataflow | ( | Expr | expr, |
FCheckVisited | fcheck_visited, | ||
FVisitLeaf | fvisit_leaf | ||
) |
void tvm::relay::ExpandDataflow | ( | Expr | expr, |
FCheckVisited | fcheck_visited, | ||
FVisitLeaf | fvisit_leaf, | ||
FExpandExpr | fexpand_expr | ||
) |
A function to iteratively traverse dataflow regions of a graph.
ExpandDataflow manually manages a stack and performs DFS to determine the processing order of nodes in an input graph.
By default fexpand_expr implemented in a way that if it finds a dataflow node (Call, Tuple, TupleGetItem), it checks if the arguments to that node need to be processed via fcheck_visited. If so, the function pushes those arguments to the stack and continues iteratively to process the top of the stack. When it finds a node that doesn't match the dataflow types, or a node who's inputs have all been processed, it visits the current leaf via fvisit_leaf.
This function should be used internally to other classes to implement mixed-mode traversals. The expectation is that fvisit_leaf will perform recursive analysis within mixed-mode traversal if it hits a non-dataflow node.
fcheck_visited, fvisit_leaf and fexpand_expr are templated to encourage reusing.
std::vector<TensorType> tvm::relay::FlattenTupleType | ( | const Type & | type | ) |
Expr tvm::relay::ForwardRewrite | ( | const Expr & | expr, |
const FForwardRewrite & | rewrite_func, | ||
std::function< ObjectRef(const Call &)> | fcontext = nullptr , |
||
std::function< Expr(const Expr &)> | fmulti_ref_trigger = nullptr |
||
) |
Apply rewrite rules to rewrite the expr in post DFS order. This function is used as a helper function to rewrtie an expression in a pass.
expr | The expression. |
rewrite_func | The rewrite func that will apply to all operators. |
fcontext | Additional callback to provide context argument for each call node. |
fmulti_ref_trigger | Transformation function to be called when an Expr consumed by multiple callers. |
Expr tvm::relay::ForwardRewrite | ( | const Expr & | expr, |
const String & | rewrite_map_attr_name, | ||
std::function< ObjectRef(const Call &)> | fcontext = nullptr , |
||
std::function< Expr(const Expr &)> | fmulti_ref_trigger = nullptr |
||
) |
Apply rewrite rules to rewrite the expr in post DFS order. This function is used as a helper function to rewrtie an expression in a pass.
expr | The expression. |
rewrite_map_attr_name | The Op's attr name which corresponds to the rewrite rule function. |
fcontext | Additional callback to provide context argument for each call node. |
fmulti_ref_trigger | Transformation function to be called when an Expr consumed by multiple callers. |
tvm::Array<TypeVar> tvm::relay::FreeTypeVars | ( | const Expr & | expr, |
const IRModule & | mod | ||
) |
Get free TypeVars from expression expr.
Free type parameters are type parameters that are not bound by a function type in the context.
expr | the expression. |
mod | the module. |
tvm::Array<TypeVar> tvm::relay::FreeTypeVars | ( | const Type & | t, |
const IRModule & | mod | ||
) |
Get free TypeVars from type t.
Free type parameters are type parameters that are not bound by a function type in the context.
t | the type. |
mod | the module. |
tvm::Array<Var> tvm::relay::FreeVars | ( | const Expr & | expr | ) |
Get free type parameters from expression expr.
Free variables are variables that are not bound by a let or a function parameter in the context.
expr | the expression. |
Get the updated module for collecting calibration data.
mod | The module to be updated. |
Get the output map between subgrpahs and its inputs/output.
mod | The module for running calibration. |
Get reference counter of each internal ExprNode in body.
body | The body expression. |
Infer the type of an expression.
expr | The expression to rewrite |
DFPattern tvm::relay::IsConstant | ( | ) |
Syntatic Sugar for creating a ConstantPattern.
Syntatic Sugar for creating a ExprPattern.
Syntatic Sugar for creating a ExprPattern base on an Op.
Syntatic Sugar for creating a TuplePattern.
Syntatic Sugar for creating a TupleGetItemPattern.
Syntatic Sugar for creating a VarPattern with a name.
DFPattern tvm::relay::IsWildcard | ( | ) |
Syntatic Sugar for creating a WildcardPattern.
Kind tvm::relay::KindCheck | ( | const Type & | t, |
const IRModule & | mod, | ||
Optional< DiagnosticContext > | diag_ctx = Optional< DiagnosticContext >() |
||
) |
Check that types are well kinded by applying "kinding rules".
This pass ensures we do not do things that violate the design of the type system when writing down types.
For example tensors are not allowed to contain functions in Relay.
We check this by ensuring the dtype
field of a Tensor always contains a data type such as int
, float
, uint
.
t | The type to check. |
mod | The global module. |
diag_ctx | The Diagnostic context. |
Determine if a pattern matches an expression.
pattern | The pattern to match |
expr | The expression to match |
|
inline |
IRModule tvm::relay::ParseModule | ( | const std::string & | file_name, |
const std::string & | file_content, | ||
const Optional< IRModule > & | init_module = Optional< IRModule >() , |
||
const MetaTable & | init_meta_table = MetaTable() |
||
) |
Expr tvm::relay::PartitionPattern | ( | DFPattern | pattern, |
Expr | expr, | ||
Map< String, ObjectRef > | attrs, | ||
PackedFunc | check | ||
) |
Partition all matches of a DFPattern inside an Expr into separate Function calls.
pattern | The pattern to match |
expr | The expression to patition |
attrs | A set of parameter names and values to apply to the partitioned function |
check | A callback function for checking more complicated properties of the matched expressions, returns true if the match is accepted and false otherwise |
Expr tvm::relay::PostOrderRewrite | ( | const Expr & | expr, |
ExprRewriter * | rewriter | ||
) |
Non-recursive DFS Graph Traversal for Custom Rewriting Passes.
PostOrderRewrite does a non-recursive traversal of the graph in Post-DFS order and calls the ExprRewriter's Rewrite functions on nodes once their inputs are rewritten. At each rewrite call, PostOrderRewrite provides the original node and the node with altered inputs for use by the ExprRewriter.
recursively visit the ir in post DFS order node, apply fvisit Each node is guaranteed to be visited only once.
node | The ir to be visited. |
fvisit | The visitor function to be applied. |
Pretty print a node for debug purposes.
node | The node to be printed. |
Rewrite the annotated program.
expr | The expression. |
fallback_device | The fallback device which is the default device for operators without annotation. |
Expr tvm::relay::RewritePatterns | ( | Array< DFPatternCallback > | callbacks, |
Expr | expr, | ||
IRModule | mod = IRModule() |
||
) |
Rewrite an expression based on some number of DFPatternCallbacks.
callbacks | An array of DFPatternCallback Nodes |
expr | The expression to rewrite |
mod | The module that associates with the expr |
Function tvm::relay::SubstituteBoundVars | ( | const Function & | func, |
const tvm::Map< Var, Expr > & | binds | ||
) |
Substitute variables with new variables (including function parameters) in a function. This is a helper function usually called by other pass functions to help optimizations. Expects all values in the bind map to be Vars.
func | The input function. |
binds | The variable to expression map that will be used to help the binding. |
Turn an expression into continuation passing style(CPS).
CPS mean that every function will, instead of returning the result directly, be passed down an extra function (called the continuation) as argument, and pass the result to the continuation instead.
Thus, every function call has to be passed an extra argument that represent the rest of the computation (Hence the name of continuation).
Similarly, all other compute will be wrapped and call the continuation as well.
f | the function. |
mod | the module. |
Remove the continuation argument of a CPS function.
Note that this only transform the type back into un-CPS form when there is no higher order input/output.
f | the function. |
Finds cases that the given match expression does not catch, if any.
match | the match expression to test |
mod | The module used for accessing global type var definitions, can be None. |
bool tvm::relay::WellFormed | ( | const Expr & | expr, |
Optional< DiagnosticContext > | diag_ctx = Optional< DiagnosticContext >() |
||
) |
Check that each Var is only bound once.
For example, the expression let x = 1 in let x = 2 in 3
bound x twice.
let f = (x -> x) in let g = (x -> x + 1) in f(g(2))
also bound x twice, although x is not shadowed.
expr | the expression to check. |
diag_ctx | the diagnostic context |
Call tvm::relay::WithFields | ( | Call | call, |
Optional< Expr > | opt_op = Optional< Expr >() , |
||
Optional< Array< Expr >> | opt_args = Optional< Array< Expr >>() , |
||
Optional< Attrs > | opt_attrs = Optional< Attrs >() , |
||
Optional< Array< Type >> | opt_type_args = Optional< Array< Type >>() , |
||
Optional< VirtualDevice > | opt_virtual_device = Optional< VirtualDevice >() , |
||
Optional< Span > | opt_span = Optional< Span >() |
||
) |
Returns call
with the given properties. A null property denotes 'no change'. Returns call
if all properties are unchanged. Otherwise, returns a copy with the new fields.
Clause tvm::relay::WithFields | ( | Clause | clause, |
Optional< Pattern > | opt_lhs = Optional< Pattern >() , |
||
Optional< Expr > | opt_rhs = Optional< Expr >() |
||
) |
Returns clause
with the given properties. A null property denotes 'no change'. Returns clause
if all properties are unchanged. Otherwise, returns a copy with the new fields.
Constant tvm::relay::WithFields | ( | Constant | constant, |
Optional< runtime::NDArray > | opt_data = {} , |
||
Optional< VirtualDevice > | opt_virtual_device = {} , |
||
Optional< Span > | opt_span = {} |
||
) |
Returns constant
with the given properties. A null property denotes 'no change'. Returns constant
if all properties are unchanged. Otherwise, returns a copy with the new fields.
Function tvm::relay::WithFields | ( | Function | function, |
Optional< Array< Var >> | opt_params = Optional< Array< Var >>() , |
||
Optional< Expr > | opt_body = Optional< Expr >() , |
||
Optional< Type > | opt_ret_type = Optional< Type >() , |
||
Optional< Array< TypeVar >> | opt_ty_params = Optional< Array< TypeVar >>() , |
||
Optional< DictAttrs > | opt_attrs = Optional< DictAttrs >() , |
||
Optional< VirtualDevice > | opt_virtual_device = Optional< VirtualDevice >() , |
||
Optional< Span > | opt_span = Optional< Span >() |
||
) |
Returns function
with the given properties. A null property denotes 'no change'. Returns function
if all properties are unchanged. Otherwise, returns a copy with the new fields.
If tvm::relay::WithFields | ( | If | if_expr, |
Optional< Expr > | opt_cond = Optional< Expr >() , |
||
Optional< Expr > | opt_true_branch = Optional< Expr >() , |
||
Optional< Expr > | opt_false_branch = Optional< Expr >() , |
||
Optional< VirtualDevice > | opt_virtual_device = Optional< VirtualDevice >() , |
||
Optional< Span > | opt_span = Optional< Span >() |
||
) |
Returns if_expr
with the given properties. A null property denotes 'no change'. Returns if_expr
if all properties are unchanged. Otherwise, returns a copy with the new fields.
Let tvm::relay::WithFields | ( | Let | let, |
Optional< Var > | opt_var = Optional< Var >() , |
||
Optional< Expr > | opt_value = Optional< Expr >() , |
||
Optional< Expr > | opt_body = Optional< Expr >() , |
||
Optional< VirtualDevice > | opt_virtual_device = Optional< VirtualDevice >() , |
||
Optional< Span > | opt_span = Optional< Span >() |
||
) |
Returns let
with the given properties. A null property denotes 'no change'. Returns let
if all properties are unchanged. Otherwise, returns a copy with the new fields.
Match tvm::relay::WithFields | ( | Match | match, |
Optional< Expr > | opt_data = Optional< Expr >() , |
||
Optional< Array< Clause >> | opt_clauses = Optional< Array< Clause >>() , |
||
Optional< Bool > | opt_complete = Optional< Bool >() , |
||
Optional< Span > | opt_span = Optional< Span >() |
||
) |
Returns match
with the given properties. A null property denotes 'no change'. Returns match
if all properties are unchanged. Otherwise, returns a copy with the new fields.
RefCreate tvm::relay::WithFields | ( | RefCreate | ref_create, |
Optional< Expr > | opt_value = Optional< Expr >() , |
||
Optional< VirtualDevice > | opt_virtual_device = Optional< VirtualDevice >() , |
||
Optional< Span > | opt_span = Optional< Span >() |
||
) |
Returns ref_create
with the given properties. A null property denotes 'no change'. Returns ref_crete
if all properties are unchanged. Otherwise, returns a copy with the new fields.
RefRead tvm::relay::WithFields | ( | RefRead | ref_read, |
Optional< Expr > | opt_ref = Optional< Expr >() , |
||
Optional< VirtualDevice > | opt_virtual_device = Optional< VirtualDevice >() , |
||
Optional< Span > | opt_span = Optional< Span >() |
||
) |
Returns ref_read
with the given properties. A null property denotes 'no change'. Returns ref_read
if all properties are unchanged. Otherwise, returns a copy with the new fields.
RefWrite tvm::relay::WithFields | ( | RefWrite | ref_write, |
Optional< Expr > | opt_ref = Optional< Expr >() , |
||
Optional< Expr > | opt_value = Optional< Expr >() , |
||
Optional< VirtualDevice > | opt_virtual_device = Optional< VirtualDevice >() , |
||
Optional< Span > | opt_span = Optional< Span >() |
||
) |
Returns ref_write
with the given properties. A null property denotes 'no change'. Returns ref_write
if all properties are unchanged. Otherwise, returns a copy with the new fields.
Tuple tvm::relay::WithFields | ( | Tuple | tuple, |
Optional< Array< Expr >> | opt_fields = Optional< Array< Expr >>() , |
||
Optional< VirtualDevice > | opt_virtual_device = Optional< VirtualDevice >() , |
||
Optional< Span > | opt_span = Optional< Span >() |
||
) |
Returns tuple
with the given properties. A null property denotes 'no change'. Returns tuple
if all properties are unchanged. Otherwise, returns a copy with the new fields.
TupleGetItem tvm::relay::WithFields | ( | TupleGetItem | tuple_get_item, |
Optional< Expr > | opt_tuple = Optional< Expr >() , |
||
Optional< Integer > | opt_index = Optional< Integer >() , |
||
Optional< VirtualDevice > | opt_virtual_device = Optional< VirtualDevice >() , |
||
Optional< Span > | opt_span = Optional< Span >() |
||
) |
Returns tuple_get_item
with the given properties. A null property denotes 'no change'. Returns tuple_get_item
if all properties are unchanged. Otherwise, returns a copy with the new fields.
Var tvm::relay::WithFields | ( | Var | var, |
Optional< Id > | opt_vid = Optional< Id >() , |
||
Optional< Type > | opt_type_annotation = Optional< Type >() , |
||
Optional< VirtualDevice > | opt_virtual_device = Optional< VirtualDevice >() , |
||
Optional< Span > | opt_span = Optional< Span >() |
||
) |
Returns var
with the given properties. A null property denotes 'no change'. Returns var
if all properties are unchanged. Otherwise, returns a copy with the new fields.
|
constexpr |