diff --git a/lib/Conversion/TosaToTTIR/TosaToTTIRPatterns.cpp b/lib/Conversion/TosaToTTIR/TosaToTTIRPatterns.cpp index b864a111a..7ab3ed5d2 100644 --- a/lib/Conversion/TosaToTTIR/TosaToTTIRPatterns.cpp +++ b/lib/Conversion/TosaToTTIR/TosaToTTIRPatterns.cpp @@ -88,18 +88,31 @@ void addElementwiseUnaryOpsConversionPatterns(MLIRContext *ctx, patterns.add>( typeConverter, ctx); - patterns.add>( + patterns.add>(typeConverter, ctx); + patterns.add>( typeConverter, ctx); - patterns.add>( + patterns.add>( + typeConverter, ctx); + patterns.add>( typeConverter, ctx); patterns.add>(typeConverter, ctx); + tosa::FloorOp, mlir::tt::ttir::FloorOp>>(typeConverter, ctx); + patterns.add>( + typeConverter, ctx); patterns.add>(typeConverter, ctx); patterns.add>(typeConverter, ctx); + patterns.add>(typeConverter, ctx); + patterns.add>( + typeConverter, ctx); } void addElementwiseBinaryOpsConversionPatterns(MLIRContext *ctx, @@ -108,29 +121,47 @@ void addElementwiseBinaryOpsConversionPatterns(MLIRContext *ctx, patterns.add>( typeConverter, ctx); + patterns.add>(typeConverter, ctx); + patterns.add>(typeConverter, ctx); patterns.add(typeConverter, ctx); patterns.add>(typeConverter, ctx); +} + +void addElementwiseTernaryOpsConversionPatterns(MLIRContext *ctx, + RewritePatternSet &patterns, + TypeConverter &typeConverter) { patterns.add>(typeConverter, ctx); + tosa::SelectOp, mlir::tt::ttir::WhereOp>>(typeConverter, ctx); +} + +void addLogicalOpsConversionPatterns(MLIRContext *ctx, + RewritePatternSet &patterns, + TypeConverter &typeConverter) { patterns.add>(typeConverter, ctx); + tosa::LogicalAndOp, mlir::tt::ttir::LogicalAndOp>>(typeConverter, ctx); + patterns.add>(typeConverter, ctx); + patterns.add>(typeConverter, ctx); + patterns.add>(typeConverter, ctx); } void addCompareOpsConversionPatterns(MLIRContext *ctx, RewritePatternSet &patterns, TypeConverter &typeConverter) { + patterns.add>(typeConverter, ctx); patterns.add>(typeConverter, ctx); -} - -void addElementwiseTernaryOpsConversionPatterns(MLIRContext *ctx, - RewritePatternSet &patterns, - TypeConverter &typeConverter) { patterns.add>(typeConverter, ctx); + tosa::GreaterOp, mlir::tt::ttir::GreaterThanOp>>(typeConverter, ctx); } + } // namespace namespace mlir::tt { @@ -140,6 +171,7 @@ void populateTosaToTTIRPatterns(MLIRContext *ctx, RewritePatternSet &patterns, addElementwiseUnaryOpsConversionPatterns(ctx, patterns, typeConverter); addElementwiseBinaryOpsConversionPatterns(ctx, patterns, typeConverter); addElementwiseTernaryOpsConversionPatterns(ctx, patterns, typeConverter); + addLogicalOpsConversionPatterns(ctx, patterns, typeConverter); addCompareOpsConversionPatterns(ctx, patterns, typeConverter); } diff --git a/test/ttmlir/Conversion/TosaToTTIR/compare/equal.mlir b/test/ttmlir/Conversion/TosaToTTIR/compare/equal.mlir new file mode 100644 index 000000000..20387a6f1 --- /dev/null +++ b/test/ttmlir/Conversion/TosaToTTIR/compare/equal.mlir @@ -0,0 +1,10 @@ +// RUN: ttmlir-opt --convert-tosa-to-ttir %s | FileCheck %s +module attributes {} { + func.func @test_equal(%arg0: tensor<13x21x3xf32>, %arg1: tensor<13x21x3xf32>) -> tensor<13x21x3xi1> { + %0 = tosa.equal %arg0, %arg1 : (tensor<13x21x3xf32>, tensor<13x21x3xf32>) -> tensor<13x21x3xi1> + // CHECK: [[VAL0:%[0-9]+]] = tensor.empty() : [[TENSOR_SIZE:tensor<13x21x3xi1>]] + // CHECK: [[VAL1:%[0-9]+]] = "ttir.eq"(%arg{{[0-9]+}}, %arg{{[0-9]+}}, [[VAL0]]){{.+}}: (tensor<13x21x3xf32>, tensor<13x21x3xf32>, [[TENSOR_SIZE]]) -> [[TENSOR_SIZE]] + return %0 : tensor<13x21x3xi1> + // CHECK: return [[VAL1]] : [[TENSOR_SIZE]] + } +} diff --git a/test/ttmlir/Conversion/TosaToTTIR/compare/greater.mlir b/test/ttmlir/Conversion/TosaToTTIR/compare/greater.mlir new file mode 100644 index 000000000..748749299 --- /dev/null +++ b/test/ttmlir/Conversion/TosaToTTIR/compare/greater.mlir @@ -0,0 +1,10 @@ +// RUN: ttmlir-opt --convert-tosa-to-ttir %s | FileCheck %s +module attributes {} { + func.func @test_greater(%arg0: tensor<13x21x3xf32>, %arg1: tensor<13x21x3xf32>) -> tensor<13x21x3xi1> { + %0 = tosa.greater %arg0, %arg1 : (tensor<13x21x3xf32>, tensor<13x21x3xf32>) -> tensor<13x21x3xi1> + // CHECK: [[VAL0:%[0-9]+]] = tensor.empty() : [[TENSOR_SIZE:tensor<13x21x3xi1>]] + // CHECK: [[VAL1:%[0-9]+]] = "ttir.gt"(%arg{{[0-9]+}}, %arg{{[0-9]+}}, [[VAL0]]){{.+}}: (tensor<13x21x3xf32>, tensor<13x21x3xf32>, [[TENSOR_SIZE]]) -> [[TENSOR_SIZE]] + return %0 : tensor<13x21x3xi1> + // CHECK: return [[VAL1]] : [[TENSOR_SIZE]] + } +} diff --git a/test/ttmlir/Conversion/TosaToTTIR/compare/greater_equal.mlir b/test/ttmlir/Conversion/TosaToTTIR/compare/greater_equal.mlir new file mode 100644 index 000000000..479af3815 --- /dev/null +++ b/test/ttmlir/Conversion/TosaToTTIR/compare/greater_equal.mlir @@ -0,0 +1,10 @@ +// RUN: ttmlir-opt --convert-tosa-to-ttir %s | FileCheck %s +module attributes {} { + func.func @test_greater_equal(%arg0: tensor<13x21x3xf32>, %arg1: tensor<13x21x3xf32>) -> tensor<13x21x3xi1> { + %0 = tosa.greater_equal %arg0, %arg1 : (tensor<13x21x3xf32>, tensor<13x21x3xf32>) -> tensor<13x21x3xi1> + // CHECK: [[VAL0:%[0-9]+]] = tensor.empty() : [[TENSOR_SIZE:tensor<13x21x3xi1>]] + // CHECK: [[VAL1:%[0-9]+]] = "ttir.ge"(%arg{{[0-9]+}}, %arg{{[0-9]+}}, [[VAL0]]){{.+}}: (tensor<13x21x3xf32>, tensor<13x21x3xf32>, [[TENSOR_SIZE]]) -> [[TENSOR_SIZE]] + return %0 : tensor<13x21x3xi1> + // CHECK: return [[VAL1]] : [[TENSOR_SIZE]] + } +} diff --git a/test/ttmlir/Conversion/TosaToTTIR/elementwise_binary/add.mlir b/test/ttmlir/Conversion/TosaToTTIR/elementwise_binary/add.mlir new file mode 100644 index 000000000..b16e8e40c --- /dev/null +++ b/test/ttmlir/Conversion/TosaToTTIR/elementwise_binary/add.mlir @@ -0,0 +1,10 @@ +// RUN: ttmlir-opt --convert-tosa-to-ttir %s | FileCheck %s +module attributes {} { + func.func @test_add(%arg0: tensor<13x21x3xf32>, %arg1: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> { + %0 = tosa.add %arg0, %arg1 {shift = 0 : i8} : (tensor<13x21x3xf32>, tensor<13x21x3xf32>) -> tensor<13x21x3xf32> + // CHECK: [[VAL0:%[0-9]+]] = tensor.empty() : [[TENSOR_SIZE:tensor<13x21x3xf32>]] + // CHECK: [[VAL1:%[0-9]+]] = "ttir.add"(%arg{{[0-9]+}}, %arg{{[0-9]+}}, [[VAL0]]){{.+}}: ([[TENSOR_SIZE]], [[TENSOR_SIZE]], [[TENSOR_SIZE]]) -> [[TENSOR_SIZE]] + return %0 : tensor<13x21x3xf32> + // CHECK: return [[VAL1]] : [[TENSOR_SIZE]] + } +} diff --git a/test/ttmlir/Conversion/TosaToTTIR/elementwise_binary/maximum_op.mlir b/test/ttmlir/Conversion/TosaToTTIR/elementwise_binary/maximum.mlir similarity index 100% rename from test/ttmlir/Conversion/TosaToTTIR/elementwise_binary/maximum_op.mlir rename to test/ttmlir/Conversion/TosaToTTIR/elementwise_binary/maximum.mlir diff --git a/test/ttmlir/Conversion/TosaToTTIR/elementwise_binary/minimum_op.mlir b/test/ttmlir/Conversion/TosaToTTIR/elementwise_binary/minimum.mlir similarity index 100% rename from test/ttmlir/Conversion/TosaToTTIR/elementwise_binary/minimum_op.mlir rename to test/ttmlir/Conversion/TosaToTTIR/elementwise_binary/minimum.mlir diff --git a/test/ttmlir/Dialect/TTIR/tosa_to_ttir_multiply.mlir b/test/ttmlir/Conversion/TosaToTTIR/elementwise_binary/mul.mlir similarity index 53% rename from test/ttmlir/Dialect/TTIR/tosa_to_ttir_multiply.mlir rename to test/ttmlir/Conversion/TosaToTTIR/elementwise_binary/mul.mlir index fd35f0cd1..137939fcf 100644 --- a/test/ttmlir/Dialect/TTIR/tosa_to_ttir_multiply.mlir +++ b/test/ttmlir/Conversion/TosaToTTIR/elementwise_binary/mul.mlir @@ -1,10 +1,10 @@ // RUN: ttmlir-opt --convert-tosa-to-ttir %s | FileCheck %s -#any_device = #tt.operand_constraint module attributes {} { func.func @test_mul(%arg0: tensor<13x21x3xf32>, %arg1: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> { %0 = tosa.mul %arg0, %arg1 {shift = 0 : i8} : (tensor<13x21x3xf32>, tensor<13x21x3xf32>) -> tensor<13x21x3xf32> - // CHECK: %[[C:.*]] = tensor.empty[[C:.*]] - // CHECK: %[[C:.*]] = "ttir.multiply"[[C:.*]] + // CHECK: [[VAL0:%[0-9]+]] = tensor.empty() : [[TENSOR_SIZE:tensor<13x21x3xf32>]] + // CHECK: [[VAL1:%[0-9]+]] = "ttir.multiply"(%arg{{[0-9]+}}, %arg{{[0-9]+}}, [[VAL0]]){{.+}}: ([[TENSOR_SIZE]], [[TENSOR_SIZE]], [[TENSOR_SIZE]]) -> [[TENSOR_SIZE]] return %0 : tensor<13x21x3xf32> + // CHECK: return [[VAL1]] : [[TENSOR_SIZE]] } } diff --git a/test/ttmlir/Conversion/TosaToTTIR/elementwise_binary/subtract_op.mlir b/test/ttmlir/Conversion/TosaToTTIR/elementwise_binary/sub.mlir similarity index 100% rename from test/ttmlir/Conversion/TosaToTTIR/elementwise_binary/subtract_op.mlir rename to test/ttmlir/Conversion/TosaToTTIR/elementwise_binary/sub.mlir diff --git a/test/ttmlir/Conversion/TosaToTTIR/elementwise_ternary/select_op.mlir b/test/ttmlir/Conversion/TosaToTTIR/elementwise_ternary/select.mlir similarity index 100% rename from test/ttmlir/Conversion/TosaToTTIR/elementwise_ternary/select_op.mlir rename to test/ttmlir/Conversion/TosaToTTIR/elementwise_ternary/select.mlir diff --git a/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/abs.mlir b/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/abs.mlir new file mode 100644 index 000000000..9df5a2828 --- /dev/null +++ b/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/abs.mlir @@ -0,0 +1,10 @@ +// RUN: ttmlir-opt --convert-tosa-to-ttir %s | FileCheck %s +module attributes {} { + func.func @test_abs(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> { + %0 = tosa.abs %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf32> + // CHECK: [[VAL0:%[0-9]+]] = tensor.empty() : [[TENSOR_SIZE:tensor<13x21x3xf32>]] + // CHECK: [[VAL1:%[0-9]+]] = "ttir.abs"(%arg{{[0-9]+}}, [[VAL0]]){{.+}}: ([[TENSOR_SIZE]], [[TENSOR_SIZE]]) -> [[TENSOR_SIZE]] + return %0 : tensor<13x21x3xf32> + // CHECK: return [[VAL1]] : [[TENSOR_SIZE]] + } +} diff --git a/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/cast.mlir b/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/cast.mlir new file mode 100644 index 000000000..4ee3a742b --- /dev/null +++ b/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/cast.mlir @@ -0,0 +1,10 @@ +// RUN: ttmlir-opt --convert-tosa-to-ttir %s | FileCheck %s +module attributes {} { + func.func @test_cast(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xbf16> { + %0 = tosa.cast %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xbf16> + // CHECK: [[VAL0:%[0-9]+]] = tensor.empty() : [[TENSOR_SIZE:tensor<13x21x3xbf16>]] + // CHECK: [[VAL1:%[0-9]+]] = "ttir.typecast"(%arg{{[0-9]+}}, [[VAL0]]){{.+}}: (tensor<13x21x3xf32>, [[TENSOR_SIZE]]) -> [[TENSOR_SIZE]] + return %0 : tensor<13x21x3xbf16> + // CHECK: return [[VAL1]] : [[TENSOR_SIZE]] + } +} diff --git a/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/ceil.mlir b/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/ceil.mlir new file mode 100644 index 000000000..77dc60dc3 --- /dev/null +++ b/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/ceil.mlir @@ -0,0 +1,10 @@ +// RUN: ttmlir-opt --convert-tosa-to-ttir %s | FileCheck %s +module attributes {} { + func.func @test_ceil(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> { + %0 = tosa.ceil %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf32> + // CHECK: [[VAL0:%[0-9]+]] = tensor.empty() : [[TENSOR_SIZE:tensor<13x21x3xf32>]] + // CHECK: [[VAL1:%[0-9]+]] = "ttir.ceil"(%arg{{[0-9]+}}, [[VAL0]]){{.+}}: ([[TENSOR_SIZE]], [[TENSOR_SIZE]]) -> [[TENSOR_SIZE]] + return %0 : tensor<13x21x3xf32> + // CHECK: return [[VAL1]] : [[TENSOR_SIZE]] + } +} diff --git a/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/cos.mlir b/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/cos.mlir new file mode 100644 index 000000000..1a8aafd6b --- /dev/null +++ b/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/cos.mlir @@ -0,0 +1,10 @@ +// RUN: ttmlir-opt --convert-tosa-to-ttir %s | FileCheck %s +module attributes {} { + func.func @test_cos(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> { + %0 = tosa.cos %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf32> + // CHECK: [[VAL0:%[0-9]+]] = tensor.empty() : [[TENSOR_SIZE:tensor<13x21x3xf32>]] + // CHECK: [[VAL1:%[0-9]+]] = "ttir.cos"(%arg{{[0-9]+}}, [[VAL0]]){{.+}}: ([[TENSOR_SIZE]], [[TENSOR_SIZE]]) -> [[TENSOR_SIZE]] + return %0 : tensor<13x21x3xf32> + // CHECK: return [[VAL1]] : [[TENSOR_SIZE]] + } +} diff --git a/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/exp.mlir b/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/exp.mlir new file mode 100644 index 000000000..957564021 --- /dev/null +++ b/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/exp.mlir @@ -0,0 +1,10 @@ +// RUN: ttmlir-opt --convert-tosa-to-ttir %s | FileCheck %s +module attributes {} { + func.func @test_exp(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> { + %0 = tosa.exp %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf32> + // CHECK: [[VAL0:%[0-9]+]] = tensor.empty() : [[TENSOR_SIZE:tensor<13x21x3xf32>]] + // CHECK: [[VAL1:%[0-9]+]] = "ttir.exp"(%arg{{[0-9]+}}, [[VAL0]]){{.+}}: ([[TENSOR_SIZE]], [[TENSOR_SIZE]]) -> [[TENSOR_SIZE]] + return %0 : tensor<13x21x3xf32> + // CHECK: return [[VAL1]] : [[TENSOR_SIZE]] + } +} diff --git a/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/floor.mlir b/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/floor.mlir new file mode 100644 index 000000000..4653bfd3e --- /dev/null +++ b/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/floor.mlir @@ -0,0 +1,10 @@ +// RUN: ttmlir-opt --convert-tosa-to-ttir %s | FileCheck %s +module attributes {} { + func.func @test_floor(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> { + %0 = tosa.floor %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf32> + // CHECK: [[VAL0:%[0-9]+]] = tensor.empty() : [[TENSOR_SIZE:tensor<13x21x3xf32>]] + // CHECK: [[VAL1:%[0-9]+]] = "ttir.floor"(%arg{{[0-9]+}}, [[VAL0]]){{.+}}: ([[TENSOR_SIZE]], [[TENSOR_SIZE]]) -> [[TENSOR_SIZE]] + return %0 : tensor<13x21x3xf32> + // CHECK: return [[VAL1]] : [[TENSOR_SIZE]] + } +} diff --git a/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/negate_op.mlir b/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/negate.mlir similarity index 100% rename from test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/negate_op.mlir rename to test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/negate.mlir diff --git a/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/reciprocal_op.mlir b/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/reciprocal.mlir similarity index 100% rename from test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/reciprocal_op.mlir rename to test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/reciprocal.mlir diff --git a/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/rsqrt_op.mlir b/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/rsqrt.mlir similarity index 100% rename from test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/rsqrt_op.mlir rename to test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/rsqrt.mlir diff --git a/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/sigmoid_op.mlir b/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/sigmoid.mlir similarity index 100% rename from test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/sigmoid_op.mlir rename to test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/sigmoid.mlir diff --git a/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/sin_op.mlir b/test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/sin.mlir similarity index 100% rename from test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/sin_op.mlir rename to test/ttmlir/Conversion/TosaToTTIR/elementwise_unary/sin.mlir diff --git a/test/ttmlir/Conversion/TosaToTTIR/logical/logical_and.mlir b/test/ttmlir/Conversion/TosaToTTIR/logical/logical_and.mlir new file mode 100644 index 000000000..adab66f3a --- /dev/null +++ b/test/ttmlir/Conversion/TosaToTTIR/logical/logical_and.mlir @@ -0,0 +1,10 @@ +// RUN: ttmlir-opt --convert-tosa-to-ttir %s | FileCheck %s +module attributes {} { + func.func @test_logical_and(%arg0: tensor<13x21x3xi1>, %arg1: tensor<13x21x3xi1>) -> tensor<13x21x3xi1> { + %0 = tosa.logical_and %arg0, %arg1 : (tensor<13x21x3xi1>, tensor<13x21x3xi1>) -> tensor<13x21x3xi1> + // CHECK: [[VAL0:%[0-9]+]] = tensor.empty() : [[TENSOR_SIZE:tensor<13x21x3xi1>]] + // CHECK: [[VAL1:%[0-9]+]] = "ttir.logical_and"(%arg{{[0-9]+}}, %arg{{[0-9]+}}, [[VAL0]]){{.+}}: ([[TENSOR_SIZE]], [[TENSOR_SIZE]], [[TENSOR_SIZE]]) -> [[TENSOR_SIZE]] + return %0 : tensor<13x21x3xi1> + // CHECK: return [[VAL1]] : [[TENSOR_SIZE]] + } +} diff --git a/test/ttmlir/Conversion/TosaToTTIR/logical/logical_not.mlir b/test/ttmlir/Conversion/TosaToTTIR/logical/logical_not.mlir new file mode 100644 index 000000000..ca74f1ab9 --- /dev/null +++ b/test/ttmlir/Conversion/TosaToTTIR/logical/logical_not.mlir @@ -0,0 +1,10 @@ +// RUN: ttmlir-opt --convert-tosa-to-ttir %s | FileCheck %s +module attributes {} { + func.func @test_logical_not(%arg0: tensor<13x21x3xi1>) -> tensor<13x21x3xi1> { + %0 = tosa.logical_not %arg0 : (tensor<13x21x3xi1>) -> tensor<13x21x3xi1> + // CHECK: [[VAL0:%[0-9]+]] = tensor.empty() : [[TENSOR_SIZE:tensor<13x21x3xi1>]] + // CHECK: [[VAL1:%[0-9]+]] = "ttir.logical_not"(%arg{{[0-9]+}}, [[VAL0]]){{.+}}: ([[TENSOR_SIZE]], [[TENSOR_SIZE]]) -> [[TENSOR_SIZE]] + return %0 : tensor<13x21x3xi1> + // CHECK: return [[VAL1]] : [[TENSOR_SIZE]] + } +} diff --git a/test/ttmlir/Conversion/TosaToTTIR/logical/logical_or.mlir b/test/ttmlir/Conversion/TosaToTTIR/logical/logical_or.mlir new file mode 100644 index 000000000..4a4ab6eae --- /dev/null +++ b/test/ttmlir/Conversion/TosaToTTIR/logical/logical_or.mlir @@ -0,0 +1,10 @@ +// RUN: ttmlir-opt --convert-tosa-to-ttir %s | FileCheck %s +module attributes {} { + func.func @test_logical_or(%arg0: tensor<13x21x3xi1>, %arg1: tensor<13x21x3xi1>) -> tensor<13x21x3xi1> { + %0 = tosa.logical_or %arg0, %arg1 : (tensor<13x21x3xi1>, tensor<13x21x3xi1>) -> tensor<13x21x3xi1> + // CHECK: [[VAL0:%[0-9]+]] = tensor.empty() : [[TENSOR_SIZE:tensor<13x21x3xi1>]] + // CHECK: [[VAL1:%[0-9]+]] = "ttir.logical_or"(%arg{{[0-9]+}}, %arg{{[0-9]+}}, [[VAL0]]){{.+}}: ([[TENSOR_SIZE]], [[TENSOR_SIZE]], [[TENSOR_SIZE]]) -> [[TENSOR_SIZE]] + return %0 : tensor<13x21x3xi1> + // CHECK: return [[VAL1]] : [[TENSOR_SIZE]] + } +} diff --git a/test/ttmlir/Conversion/TosaToTTIR/logical/logical_xor.mlir b/test/ttmlir/Conversion/TosaToTTIR/logical/logical_xor.mlir new file mode 100644 index 000000000..649269156 --- /dev/null +++ b/test/ttmlir/Conversion/TosaToTTIR/logical/logical_xor.mlir @@ -0,0 +1,10 @@ +// RUN: ttmlir-opt --convert-tosa-to-ttir %s | FileCheck %s +module attributes {} { + func.func @test_logical_xor(%arg0: tensor<13x21x3xi1>, %arg1: tensor<13x21x3xi1>) -> tensor<13x21x3xi1> { + %0 = tosa.logical_xor %arg0, %arg1 : (tensor<13x21x3xi1>, tensor<13x21x3xi1>) -> tensor<13x21x3xi1> + // CHECK: [[VAL0:%[0-9]+]] = tensor.empty() : [[TENSOR_SIZE:tensor<13x21x3xi1>]] + // CHECK: [[VAL1:%[0-9]+]] = "ttir.logical_xor"(%arg{{[0-9]+}}, %arg{{[0-9]+}}, [[VAL0]]){{.+}}([[TENSOR_SIZE]], [[TENSOR_SIZE]], [[TENSOR_SIZE]]) -> [[TENSOR_SIZE]] + return %0 : tensor<13x21x3xi1> + // CHECK: return [[VAL1]] : [[TENSOR_SIZE]] + } +}