[Mlir-commits] [mlir] [mlir][tosa] Add infer shape test of scalar mul op (PR #128091)

Tai Ly llvmlistbot at llvm.org
Thu Feb 20 15:57:12 PST 2025


https://github.com/Tai78641 created https://github.com/llvm/llvm-project/pull/128091

This adds a tosa-infer-shapes test for scalar mul op


>From 03a7f911fe2f1a294c4e1983c8e515fdea7492fb Mon Sep 17 00:00:00 2001
From: Tai Ly <tai.ly at arm.com>
Date: Tue, 21 Jan 2025 21:32:02 +0000
Subject: [PATCH] [mlir][tosa] Add infer shape test of scalar mul op

This adds a tosa-infer-shapes test for scalar mul op

Signed-off-by: Tai Ly <tai.ly at arm.com>
Change-Id: I33b263da0ddae44296325a49fbb2f3ea0ccb9fc3
---
 mlir/test/Dialect/Tosa/tosa-infer-shapes.mlir | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/mlir/test/Dialect/Tosa/tosa-infer-shapes.mlir b/mlir/test/Dialect/Tosa/tosa-infer-shapes.mlir
index 7e714d0f8547a..b5b0cbff25cfd 100644
--- a/mlir/test/Dialect/Tosa/tosa-infer-shapes.mlir
+++ b/mlir/test/Dialect/Tosa/tosa-infer-shapes.mlir
@@ -1479,3 +1479,13 @@ func.func @test_multiple_non_inferrable_consumers(%arg0: tensor<1x2x8xf32>) {
   %expanded_1 = tensor.expand_shape %0 [[0], [1, 2], [3]] output_shape [%dim, 1, 4, 8] : tensor<?x2x8xf32> into tensor<?x1x2x8xf32>
   return
 }
+
+// -----
+// CHECK-LABEL: test_mul_scalar
+func.func @test_mul_scalar(%arg0: tensor<f32>, %arg1: tensor<f32>) -> tensor<*xf32> {
+  // CHECK: %[[SHIFT:.*]] = "tosa.const"() <{value = dense<0> : tensor<1xi8>}> : () -> tensor<1xi8>
+  // CHECK: tosa.mul %arg0, %arg1, %[[SHIFT]] : (tensor<f32>, tensor<f32>, tensor<1xi8>) -> tensor<f32>
+  %shift = "tosa.const"() <{value = dense<0> : tensor<1xi8>}> : () -> tensor<1xi8>
+  %0 = tosa.mul %arg0, %arg1, %shift : (tensor<f32>, tensor<f32>, tensor<1xi8>) -> tensor<*xf32>
+  return %0 : tensor<*xf32>
+}



More information about the Mlir-commits mailing list