diff --git a/include/NeuraDialect/NeuraOps.td b/include/NeuraDialect/NeuraOps.td index 88513411..37cf555a 100644 --- a/include/NeuraDialect/NeuraOps.td +++ b/include/NeuraDialect/NeuraOps.td @@ -81,8 +81,8 @@ def Neura_FMulOp : Op { def Neura_FDivOp : Op { let summary = "Floating division operation"; - let arguments = (ins AnyFloat:$lhs, AnyFloat:$rhs, Optional:$predicate); - let results = (outs AnyFloat:$result); + let arguments = (ins AnyType:$lhs, Optional:$rhs); + let results = (outs AnyType:$result); // let assemblyFormat = "$lhs `,` $rhs `,` $predicate attr-dict `:` type($result)"; } @@ -211,6 +211,54 @@ def Neura_CastOp : Op{ // let assemblyFormat = "$input type($input) `->` type($output) `,` $predicate attr-dict"; } +// Defines an alloca operation for memory allocation. +def Neura_AllocaOp : Op { + let summary = "Memory allocation operation"; + let description = [{ + Allocates memory on the stack, similar to llvm.alloca. + Takes a predicated size value and returns a pointer to the allocated memory. + + Example: + %ptr = neura.alloca %size : !neura.data -> !llvm.ptr + }]; + + let arguments = (ins AnyType:$size); + let results = (outs AnyType:$result); + let assemblyFormat = "$size attr-dict `:` type($size) `->` type($result)"; +} + +// Defines a sign extension operation. +def Neura_SExtOp : Op { + let summary = "Sign extension operation"; + let description = [{ + Sign extends a value from a smaller integer type to a larger integer type. + Similar to llvm.sext, but works with predicated values. + + Example: + %extended = neura.sext %value : !neura.data -> !neura.data + }]; + + let arguments = (ins AnyType:$value); + let results = (outs AnyType:$result); + let assemblyFormat = "$value attr-dict `:` type($value) `->` type($result)"; +} + +// Defines a zero extension operation. +def Neura_ZExtOp : Op { + let summary = "Zero extension operation"; + let description = [{ + Zero extends a value from a smaller integer type to a larger integer type. + Similar to llvm.zext, but works with predicated values. + + Example: + %extended = neura.zext %value : !neura.data -> !neura.data + }]; + + let arguments = (ins AnyType:$value); + let results = (outs AnyType:$result); + let assemblyFormat = "$value attr-dict `:` type($value) `->` type($result)"; +} + // ---------------------------------------------------- // Defines vector operations. @@ -264,7 +312,7 @@ def Neura_DataMovOp : Op { // ---------------------------------------------------- // Defines ctrl-related operations. -// Phi operation for merging values in dataflow form +// Defines phi operation for merging values in dataflow form. def Neura_PhiOp : Op { let summary = "Phi node in dataflow form"; let description = [{ @@ -280,11 +328,11 @@ def Neura_PhiOp : Op { let arguments = (ins Variadic:$inputs); let results = (outs AnyType:$result); - // Explicitly specify types for operands in the assembly format + // Explicitly specifies types for operands in the assembly format. // let assemblyFormat = "$init_val `:` type($init_val) `,` $loop_val `:` type($loop_val) attr-dict `,` type($result)"; } -// Control movement extending base move but with different signature. +// Defines control movement extending base move but with different signature. def Neura_CtrlMovOp : Op { let summary = "Control movement operation"; let description = [{ @@ -295,15 +343,15 @@ def Neura_CtrlMovOp : Op { ctrl_mov %value to %placeholder : f32 // Connect value to placeholder }]; - // Add type constraints for both operands + // Adds type constraints for both operands. let arguments = (ins AnyType:$value, AnyType:$target); let results = (outs); - // Correct assembly format - types must be space-separated + // Corrects assembly format - types must be space-separated. let assemblyFormat = "$value `->` $target attr-dict `:` type($value) type($target)"; } -// Reserve operation for control flow values. +// Defines reserve operation for control flow values. def Neura_ReserveOp : Op { let summary = "Creates a placeholder for control flow values"; let description = [{ @@ -390,7 +438,7 @@ def Neura_LoopControlOp : Op{ predicate bit is initially 0, while the start value's predicate bit is 1. Example: - // Loop control that calculates next index and validity in one step + // Shows loop control that calculates next index and validity in one step. %next_idx, %loop_valid = neura.loop_control( parent_valid = %parent_valid, start = %start_val, diff --git a/lib/Conversion/ArithToNeura/ArithToNeuraPass.cpp b/lib/Conversion/ArithToNeura/ArithToNeuraPass.cpp index 03ab2517..cb8cc039 100644 --- a/lib/Conversion/ArithToNeura/ArithToNeuraPass.cpp +++ b/lib/Conversion/ArithToNeura/ArithToNeuraPass.cpp @@ -160,8 +160,7 @@ struct ArithFDivToNeuraFDiv : public OpRewritePattern { Type result_type = op.getType(); // Optional predicate: default to null. - rewriter.replaceOpWithNewOp(op, result_type, lhs, rhs, - nullptr); + rewriter.replaceOpWithNewOp(op, result_type, lhs, rhs); return success(); } }; diff --git a/lib/Conversion/LlvmToNeura/LlvmToNeuraPass.cpp b/lib/Conversion/LlvmToNeura/LlvmToNeuraPass.cpp index ec3c3eb2..955413d6 100644 --- a/lib/Conversion/LlvmToNeura/LlvmToNeuraPass.cpp +++ b/lib/Conversion/LlvmToNeura/LlvmToNeuraPass.cpp @@ -52,7 +52,7 @@ struct LlvmFAddToNeuraFAdd : public OpRewritePattern { if (!mlir::isa(result_type)) return failure(); - // Optional predicate: default to 'none' + // Sets optional predicate: default to 'none'. rewriter.replaceOpWithNewOp(op, result_type, lhs, rhs); return success(); } @@ -72,7 +72,7 @@ struct LlvmFSubToNeuraFSub : public OpRewritePattern { return failure(); } - // Optional predicate: default to 'none'. + // Sets optional predicate: default to 'none'. rewriter.replaceOpWithNewOp(op, result_type, lhs, rhs, Value()); return success(); @@ -291,19 +291,168 @@ struct LlvmConstantToNeuraConstant : public OpRewritePattern { PatternRewriter &rewriter) const override { auto attr = op.getValue(); - // Creates operation state manually + // Creates operation state manually. OperationState state(op.getLoc(), neura::ConstantOp::getOperationName()); state.addAttribute("value", attr); state.addAttribute("predicate", rewriter.getBoolAttr(true)); state.addTypes(op.getType()); - // Creates the operation and replace + // Creates the operation and replaces. Operation *newOp = rewriter.create(state); rewriter.replaceOp(op, newOp->getResults()); return success(); } }; +struct LlvmAllocaToNeuraAlloca : public OpRewritePattern { + using OpRewritePattern::OpRewritePattern; + + LogicalResult matchAndRewrite(LLVM::AllocaOp op, + PatternRewriter &rewriter) const override { + Value size = op.getArraySize(); + Type resultType = op.getType(); + + // Converts the size to neura.data if it's not already. + // Assumes the size is already in the right format. + // Handles type conversion here. + + rewriter.replaceOpWithNewOp(op, resultType, size); + return success(); + } +}; + +struct LlvmSExtToNeuraSExt : public OpRewritePattern { + using OpRewritePattern::OpRewritePattern; + + LogicalResult matchAndRewrite(LLVM::SExtOp op, + PatternRewriter &rewriter) const override { + Value input = op.getArg(); + Type resultType = op.getType(); + + rewriter.replaceOpWithNewOp(op, resultType, input); + return success(); + } +}; + +struct LlvmZExtToNeuraZExt : public OpRewritePattern { + using OpRewritePattern::OpRewritePattern; + + LogicalResult matchAndRewrite(LLVM::ZExtOp op, + PatternRewriter &rewriter) const override { + Value input = op.getArg(); + Type resultType = op.getType(); + + rewriter.replaceOpWithNewOp(op, resultType, input); + return success(); + } +}; + +struct LlvmMulToNeuraMul : public OpRewritePattern { + using OpRewritePattern::OpRewritePattern; + + LogicalResult matchAndRewrite(LLVM::MulOp op, + PatternRewriter &rewriter) const override { + Value lhs = op.getLhs(); + Value rhs = op.getRhs(); + Type resultType = op.getType(); + + rewriter.replaceOpWithNewOp(op, resultType, lhs, rhs); + return success(); + } +}; + +struct LlvmFuncToNeuraFunc : public OpRewritePattern { + using OpRewritePattern::OpRewritePattern; + + LogicalResult matchAndRewrite(LLVM::LLVMFuncOp op, + PatternRewriter &rewriter) const override { + + + auto target = op->getAttrOfType(mlir::accel::kAcceleratorAttr); + if (!target || target.getValue() != mlir::accel::kNeuraTarget) { + return failure(); + } + + // Converts LLVMFunctionType to FunctionType. + auto llvmFuncType = op.getFunctionType(); + auto funcType = rewriter.getFunctionType( + llvmFuncType.getParams(), + llvmFuncType.getReturnType() + ); + + // Creates the new func.func operation using OperationState to have full control. + OperationState state(op.getLoc(), func::FuncOp::getOperationName()); + state.addAttribute("sym_name", rewriter.getStringAttr(op.getName())); + state.addAttribute("function_type", TypeAttr::get(funcType)); + + // Copies ALL attributes from the original llvm.func exactly as they are. + // Skips function type and name attributes as they are handled separately. + SmallVector attrs; + for (auto attr : op->getAttrs()) { + if (attr.getName() == "function_type" || attr.getName() == "sym_name") { + continue; + } + attrs.push_back(attr); + } + state.addAttributes(attrs); + + // Adds the function body region. + state.addRegion(); + + auto newFunc = cast(rewriter.create(state)); + + // Moves the function body. + rewriter.inlineRegionBefore(op.getBody(), newFunc.getBody(), newFunc.getBody().end()); + + // Replaces the old function. + rewriter.replaceOp(op, newFunc); + return success(); + } +}; + +struct LlvmCallToFuncCall : public OpRewritePattern { + using OpRewritePattern::OpRewritePattern; + + LogicalResult matchAndRewrite(LLVM::CallOp op, + PatternRewriter &rewriter) const override { + // Gets the callee name. + auto callee = op.getCallee(); + if (!callee) { + return failure(); + } + + // Checks if the callee function exists as func.func in the module. + ModuleOp module = op->getParentOfType(); + if (!module) { + return failure(); + } + + // Looks for a func.func with the same name. + func::FuncOp funcOp = module.lookupSymbol(callee.value()); + if (!funcOp) { + return failure(); + } + + // Gets the result types from the function signature. + auto resultTypes = funcOp.getFunctionType().getResults(); + + // Converts the call to func.call. + auto newCall = rewriter.create( + op.getLoc(), resultTypes, callee.value(), op.getArgOperands() + ); + + // Replaces the old call with the new one. + // Handles both cases: calls with results and calls without results. + if (op.getNumResults() == 0) { + rewriter.eraseOp(op); + } else { + rewriter.replaceOp(op, newCall->getResults()); + } + + return success(); + } +}; + struct LowerLlvmToNeuraPass : public PassWrapper> { @@ -316,6 +465,7 @@ struct LowerLlvmToNeuraPass void getDependentDialects(DialectRegistry ®istry) const override { registry.insert(); + registry.insert(); } void runOnOperation() override { @@ -338,11 +488,24 @@ struct LowerLlvmToNeuraPass patterns.add(&getContext()); patterns.add(&getContext()); patterns.add(&getContext()); + patterns.add(&getContext()); + patterns.add(&getContext()); + patterns.add(&getContext()); + patterns.add(&getContext()); + patterns.add(&getContext()); + patterns.add(&getContext()); FrozenRewritePatternSet frozen(std::move(patterns)); ModuleOp module_op = getOperation(); + // Performs function-level conversions. + if (failed(applyPatternsGreedily(module_op, frozen))) { + signalPassFailure(); + return; + } + + // Performs operation-level conversions. // Applies to every region inside the module (regardless of func type, // e.g., mlir func or llvm func). module_op.walk([&](FunctionOpInterface func) { diff --git a/test/c2llvm2mlir/nested_loop/kernel.cpp b/test/c2llvm2mlir/nested_loop/kernel.cpp new file mode 100644 index 00000000..a7fe77b6 --- /dev/null +++ b/test/c2llvm2mlir/nested_loop/kernel.cpp @@ -0,0 +1,46 @@ +// RUN: mlir-neura-opt %s | FileCheck %s + +#include + +#define NTAPS 32 + +int input[NTAPS] = { +1, 1, 1, 1, 1, 1, 1, 1, +1, 1, 1, 1, 1, 1, 1, 1, +1, 1, 1, 1, 1, 1, 1, 1, +1, 1, 1, 1, 1, 1, 1, 1 +}; +int output[NTAPS]; +int coefficients[NTAPS] = {25, 150, 375, -225, 50, 75, -300, 125, +25, 150, 375, -225, 50, 75, -300, 125, +25, 150, 375, -225, 50, 75, -300, 125, +25, 150, 375, -225, 50, 75, -300, 125}; + +void kernel(int input[], int output[], int coefficient[]); + +int main() +{ + +// input_dsp (input, NTAPS, 0); + + kernel(input, output, coefficients); + +// output_dsp (input, NTAPS, 0); +// output_dsp (coefficients, NTAPS, 0); +// output_dsp (output, NTAPS, 0); + printf("output: %d\n", output[0]); + return 0; +} + +/* input : input sample array */ +/* output: output sample array */ +/* coefficient: coefficient array */ +void kernel(int input[], int output[], int coefficient[]) { + int i, j; + + for (i = 0; i < NTAPS; ++i) { + for (j = 0; j < NTAPS; ++j) { + output[j] += input[i] * coefficient[i]; + } + } +} diff --git a/test/c2llvm2mlir/nested_loop/test.mlir b/test/c2llvm2mlir/nested_loop/test.mlir new file mode 100644 index 00000000..710b682b --- /dev/null +++ b/test/c2llvm2mlir/nested_loop/test.mlir @@ -0,0 +1,27 @@ +// RUN: clang++ -S -emit-llvm kernel.cpp -o kernel.ll +// RUN: mlir-translate --import-llvm kernel.ll -o kernel.mlir + +// RUN: mlir-neura-opt --assign-accelerator \ +// RUN: --lower-llvm-to-neura \ +// RUN: --canonicalize-live-in \ +// RUN: --leverage-predicated-value \ +// RUN: --transform-ctrl-to-data-flow \ +// RUN: --fold-constant \ +// RUN: --insert-data-mov kernel.mlir | FileCheck %s --check-prefix=CHECK-LLVM2NEURA + +// RUN: mlir-neura-opt --assign-accelerator \ +// RUN: --lower-llvm-to-neura \ +// RUN: --canonicalize-live-in \ +// RUN: --leverage-predicated-value \ +// RUN: --transform-ctrl-to-data-flow \ +// RUN: --fold-constant \ +// RUN: --insert-data-mov \ +// RUN: --map-to-accelerator="mapping-strategy=heuristic backtrack-config=simple" kernel.mlir | FileCheck %s --check-prefix=CHECK-LLVM2NEURA-MAP + +// CHECK-LLVM2NEURA: accelerator = "neura" +// CHECK-LLVM2NEURA: %25 = neura.alloca %24 : !neura.data -> !neura.data +// CHECK-LLVM2NEURA: %38 = "neura.phi"(%36, %37) : (!neura.data, !neura.data) -> !neura.data +// CHECK-LLVM2NEURA: %175 = neura.sext %174 : !neura.data -> !neura.data +// CHECK-LLVM2NEURA: %194 = "neura.mul"(%192, %193) : (!neura.data, !neura.data) -> !neura.data + +// CHECK-LLVM2NEURA-MAP: func.func @_Z6kernelPiS_S_(%arg0: !llvm.ptr {llvm.noundef}, %arg1: !llvm.ptr {llvm.noundef}, %arg2: !llvm.ptr {llvm.noundef}) -> !llvm.void attributes {CConv = #llvm.cconv, accelerator = "neura", frame_pointer = #llvm.framePointerKind, linkage = #llvm.linkage, no_inline, no_unwind, optimize_none, passthrough = ["mustprogress", ["uwtable", "2"], ["min-legal-vector-width", "0"], ["no-trapping-math", "true"], ["stack-protector-buffer-size", "8"], ["target-cpu", "x86-64"]], target_cpu = "x86-64", target_features = #llvm.target_features<["+cmov", "+cx8", "+fxsr", "+mmx", "+sse", "+sse2", "+x87"]>, tune_cpu = "generic", unnamed_addr = 0 : i64, visibility_ = 0 : i64} { \ No newline at end of file diff --git a/test/c2llvm2mlir/kernel.cpp b/test/c2llvm2mlir/simple_loop/kernel.cpp similarity index 100% rename from test/c2llvm2mlir/kernel.cpp rename to test/c2llvm2mlir/simple_loop/kernel.cpp diff --git a/test/c2llvm2mlir/test.mlir b/test/c2llvm2mlir/simple_loop/test.mlir similarity index 100% rename from test/c2llvm2mlir/test.mlir rename to test/c2llvm2mlir/simple_loop/test.mlir diff --git a/test/neura/for_loop/kernel_test.mlir b/test/neura/for_loop/kernel_test.mlir index 58b5336c..e1271f9a 100644 --- a/test/neura/for_loop/kernel_test.mlir +++ b/test/neura/for_loop/kernel_test.mlir @@ -32,7 +32,8 @@ // RUN: --insert-data-mov \ // RUN: | FileCheck %s --check-prefix=CHECK-MOV -// CHECK: llvm.func local_unnamed_addr @_Z6kernelPfS_S_(%arg0: !llvm.ptr {llvm.nocapture, llvm.noundef, llvm.readonly}, %arg1: !llvm.ptr {llvm.nocapture, llvm.noundef}, %arg2: !llvm.ptr {llvm.nocapture, llvm.noundef, llvm.readonly}) attributes {accelerator = "neura", memory_effects = #llvm.memory_effects, no_unwind, passthrough = ["mustprogress", "nofree", "norecurse", "nosync", ["uwtable", "2"], ["min-legal-vector-width", "0"], ["no-trapping-math", "true"], ["stack-protector-buffer-size", "8"], ["target-cpu", "x86-64"]], target_cpu = "x86-64", target_features = #llvm.target_features<["+cmov", "+cx8", "+fxsr", "+mmx", "+sse", "+sse2", "+x87"]>, tune_cpu = "generic"} { +// CHECK: func.func +// CHECK: accelerator = "neura" // CHECK-NEXT: %0 = "neura.constant"() <{predicate = true, value = "%arg0"}> : () -> !neura.data // CHECK-NEXT: %1 = "neura.constant"() <{predicate = true, value = "%arg1"}> : () -> !neura.data // CHECK-NEXT: %2 = "neura.constant"() <{predicate = true, value = "%arg2"}> : () -> !neura.data @@ -57,7 +58,8 @@ // CHECK-NEXT: } // Verifies the neura ops are generated. And fusion happens. -// CHECK-FUSED: llvm.func local_unnamed_addr @_Z6kernelPfS_S_(%arg0: !llvm.ptr {llvm.nocapture, llvm.noundef, llvm.readonly}, %arg1: !llvm.ptr {llvm.nocapture, llvm.noundef}, %arg2: !llvm.ptr {llvm.nocapture, llvm.noundef, llvm.readonly}) attributes {accelerator = "neura", memory_effects = #llvm.memory_effects, no_unwind, passthrough = ["mustprogress", "nofree", "norecurse", "nosync", ["uwtable", "2"], ["min-legal-vector-width", "0"], ["no-trapping-math", "true"], ["stack-protector-buffer-size", "8"], ["target-cpu", "x86-64"]], target_cpu = "x86-64", target_features = #llvm.target_features<["+cmov", "+cx8", "+fxsr", "+mmx", "+sse", "+sse2", "+x87"]>, tune_cpu = "generic"} { +// CHECK-FUSED: func.func +// CHECK-FUSED: accelerator = "neura" // CHECK-FUSED-NEXT: %0 = "neura.grant_once"() <{constant_value = "%arg0"}> : () -> !neura.data // CHECK-FUSED-NEXT: %1 = "neura.grant_once"() <{constant_value = "%arg1"}> : () -> !neura.data // CHECK-FUSED-NEXT: %2 = "neura.constant"() <{predicate = true, value = "%arg1"}> : () -> !neura.data @@ -107,7 +109,8 @@ // CHECK-FUSED-NEXT: "neura.return"() : () -> () // CHECK-FUSED-NEXT: } -// CHECK-MOV: llvm.func local_unnamed_addr @_Z6kernelPfS_S_(%arg0: !llvm.ptr {llvm.nocapture, llvm.noundef, llvm.readonly}, %arg1: !llvm.ptr {llvm.nocapture, llvm.noundef}, %arg2: !llvm.ptr {llvm.nocapture, llvm.noundef, llvm.readonly}) attributes {accelerator = "neura", memory_effects = #llvm.memory_effects, no_unwind, passthrough = ["mustprogress", "nofree", "norecurse", "nosync", ["uwtable", "2"], ["min-legal-vector-width", "0"], ["no-trapping-math", "true"], ["stack-protector-buffer-size", "8"], ["target-cpu", "x86-64"]], target_cpu = "x86-64", target_features = #llvm.target_features<["+cmov", "+cx8", "+fxsr", "+mmx", "+sse", "+sse2", "+x87"]>, tune_cpu = "generic"} { +// CHECK-MOV: func.func +// CHECK-MOV: accelerator = "neura" // CHECK-MOV-NEXT: %0 = "neura.grant_once"() <{constant_value = "%arg0"}> : () -> !neura.data // CHECK-MOV-NEXT: %1 = "neura.grant_once"() <{constant_value = "%arg1"}> : () -> !neura.data // CHECK-MOV-NEXT: %2 = "neura.constant"() <{predicate = true, value = "%arg1"}> : () -> !neura.data diff --git a/test/neura/for_loop/relu_test.mlir b/test/neura/for_loop/relu_test.mlir index e873cb82..74bd2c5c 100644 --- a/test/neura/for_loop/relu_test.mlir +++ b/test/neura/for_loop/relu_test.mlir @@ -16,7 +16,8 @@ // RUN: --transform-ctrl-to-data-flow \ // RUN: | FileCheck %s --check-prefix=CTRL2DATA -// CHECK: llvm.func local_unnamed_addr @_Z6kernelPiS_(%arg0: !llvm.ptr {llvm.nocapture, llvm.noundef, llvm.readonly}, %arg1: !llvm.ptr {llvm.nocapture, llvm.noundef}) attributes {accelerator = "neura", memory_effects = #llvm.memory_effects, no_unwind, passthrough = ["mustprogress", "nofree", "norecurse", "nosync", ["uwtable", "2"], ["min-legal-vector-width", "0"], ["no-trapping-math", "true"], ["stack-protector-buffer-size", "8"], ["target-cpu", "x86-64"]], target_cpu = "x86-64", target_features = #llvm.target_features<["+cmov", "+cx8", "+fxsr", "+mmx", "+sse", "+sse2", "+x87"]>, tune_cpu = "generic"} { +// CHECK: func.func +// CHECK: accelerator = "neura" // CHECK-NEXT: %0 = "neura.constant"() <{predicate = true, value = "%arg0"}> : () -> !llvm.ptr // CHECK-NEXT: %1 = "neura.constant"() <{predicate = true, value = "%arg1"}> : () -> !llvm.ptr // CHECK-NEXT: %2 = "neura.constant"() <{predicate = true, value = 0 : i64}> : () -> i64 @@ -44,7 +45,8 @@ // CHECK-NEXT: } -// CTRL2DATA: llvm.func local_unnamed_addr @_Z6kernelPiS_(%arg0: !llvm.ptr {llvm.nocapture, llvm.noundef, llvm.readonly}, %arg1: !llvm.ptr {llvm.nocapture, llvm.noundef}) attributes {accelerator = "neura", memory_effects = #llvm.memory_effects, no_unwind, passthrough = ["mustprogress", "nofree", "norecurse", "nosync", ["uwtable", "2"], ["min-legal-vector-width", "0"], ["no-trapping-math", "true"], ["stack-protector-buffer-size", "8"], ["target-cpu", "x86-64"]], target_cpu = "x86-64", target_features = #llvm.target_features<["+cmov", "+cx8", "+fxsr", "+mmx", "+sse", "+sse2", "+x87"]>, tune_cpu = "generic"} { +// CTRL2DATA: func.func +// CTRL2DATA: accelerator = "neura" // CTRL2DATA-NEXT: %0 = "neura.constant"() <{predicate = true, value = "%arg0"}> : () -> !neura.data // CTRL2DATA-NEXT: %1 = "neura.grant_once"(%0) : (!neura.data) -> !neura.data // CTRL2DATA-NEXT: %2 = "neura.constant"() <{predicate = true, value = "%arg1"}> : () -> !neura.data diff --git a/test/neura/interpreter/basic_operation/fdiv.mlir b/test/neura/interpreter/basic_operation/fdiv.mlir index 5b3bf0f8..af160c1b 100644 --- a/test/neura/interpreter/basic_operation/fdiv.mlir +++ b/test/neura/interpreter/basic_operation/fdiv.mlir @@ -48,23 +48,24 @@ func.func @test_fdiv_zero_dividend() -> f32 { return %res : f32 } -func.func @test_fdiv_with_predicate_true() -> f32 { - %a = arith.constant 15.0 : f32 - %b = arith.constant 3.0 : f32 - %pred = arith.constant 1 : i32 - %res = "neura.fdiv"(%a, %b, %pred) : (f32, f32, i32) -> f32 - // CHECK: [neura-interpreter] → Output: 5.000000 - return %res : f32 -} +// TODO: Remove Test with predicate because we plan to remove the predicate attribute in +// https://github.com/coredac/dataflow/issues/116 -func.func @test_fdiv_with_predicate_false() -> f32 { - %a = arith.constant 20.0 : f32 - %b = arith.constant 4.0 : f32 - %pred = arith.constant 0 : i32 - %res = "neura.fdiv"(%a, %b, %pred) : (f32, f32, i32) -> f32 - // CHECK: [neura-interpreter] → Output: 0.000000 - return %res : f32 -} +// func.func @test_fdiv_with_predicate_true() -> f32 { +// %a = arith.constant 15.0 : f32 +// %b = arith.constant 3.0 : f32 +// %pred = arith.constant 1 : i32 +// %res = "neura.fdiv"(%a, %b, %pred) : (f32, f32, i32) -> f32 +// return %res : f32 +// } + +// func.func @test_fdiv_with_predicate_false() -> f32 { +// %a = arith.constant 20.0 : f32 +// %b = arith.constant 4.0 : f32 +// %pred = arith.constant 0 : i32 +// %res = "neura.fdiv"(%a, %b, %pred) : (f32, f32, i32) -> f32 +// return %res : f32 +// } func.func @test_fdiv_f64() -> f64 { %a = arith.constant 10.5 : f64