马上毕业了给各位本科计科生几个建议
2026/6/10 3:10:22
我们看下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 (函数定义)配对使用。
def GenericCallOp : Toy_Op<"gene