MLIR专题6:函数调用
2026/6/10 1:53:54 网站建设 项目流程

我们看下toy实例中的函数调用定义:

def GenericCallOp : Toy_Op<"generic_call"> { let summary = "generic call operation"; let description = [{ Generic calls represent calls to a user defined function that needs to be specialized for the shape of its arguments. The callee name is attached as a symbol reference via an attribute. The arguments list must match the arguments expected by the callee. For example: ```mlir %4 = toy.generic_call @my_func(%1, %3) : (tensor<2x3xf64>, tensor<2x3xf64>) -> tensor<*xf64> ``` This is only valid if a function named "my_func" exists and takes two arguments. }]; // The generic call operation takes a symbol reference attribute as the // callee, and inputs for the call. let arguments = (ins FlatSymbolRefAttr:$callee, Variadic<F64Tensor>:$inputs); // The generic call operation returns a single value of TensorType. let results = (outs F64Tensor); // Specialize assembly printing and parsing using a declarative format. let assemblyFormat = [{ $callee `(` $inputs `)` attr-dict `:` functional-type($inputs, results) }]; // Add custom build methods for the generic call operation. let builders = [ OpBuilder<(ins "StringRef":$callee, "ArrayRef<Value>":$arguments)> ]; }

这是 Toy 方言中的 函数调用操作 ,与 FuncOp (函数定义)配对使用。

1. 操作声明

def GenericCallOp : Toy_Op<"gene

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询