From 8f1e7441699612d4173dd75b90a2b97b9ee5af54 Mon Sep 17 00:00:00 2001 From: Jacques Pienaar Date: Wed, 27 Mar 2019 17:33:40 -0700 Subject: [PATCH] Move test of trait using dialect ops, to dialects of ops. PiperOrigin-RevId: 240680010 --- mlir/test/Dialect/traits.mlir | 203 ------------------------------------------ 1 file changed, 203 deletions(-) delete mode 100644 mlir/test/Dialect/traits.mlir diff --git a/mlir/test/Dialect/traits.mlir b/mlir/test/Dialect/traits.mlir deleted file mode 100644 index d8c0b4a..0000000 --- a/mlir/test/Dialect/traits.mlir +++ /dev/null @@ -1,203 +0,0 @@ -// RUN: mlir-opt %s -split-input-file -verify | FileCheck %s - -// ----- - -// CHECK-LABEL: @broadcast_scalar_scalar_scalar -func @broadcast_scalar_scalar_scalar(tensor, tensor) -> tensor { -^bb0(%arg0: tensor, %arg1: tensor): - // CHECK: %0 = tfl.add %arg0, %arg1 {fused_activation_function: "RELU6"} : tensor - %0 = tfl.add %arg0, %arg1 {fused_activation_function: "RELU6"} : tensor - return %0 : tensor -} - -// ----- - -// CHECK-LABEL: @broadcast_tensor_scalar_tensor -func @broadcast_tensor_scalar_tensor(tensor<4xi32>, tensor) -> tensor<4xi32> { -^bb0(%arg0: tensor<4xi32>, %arg1: tensor): - // CHECK: %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "RELU6"} : (tensor<4xi32>, tensor) -> tensor<4xi32> - %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "RELU6"} : (tensor<4xi32>, tensor) -> tensor<4xi32> - return %0 : tensor<4xi32> -} - -// ----- - -// Check only one dimension has size 1 -// CHECK-LABEL: @broadcast_tensor_tensor_tensor -func @broadcast_tensor_tensor_tensor(tensor<4x3x2xi32>, tensor<3x1xi32>) -> tensor<4x3x2xi32> { -^bb0(%arg0: tensor<4x3x2xi32>, %arg1: tensor<3x1xi32>): - // CHECK: %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "RELU6"} : (tensor<4x3x2xi32>, tensor<3x1xi32>) -> tensor<4x3x2xi32> - %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "RELU6"} : (tensor<4x3x2xi32>, tensor<3x1xi32>) -> tensor<4x3x2xi32> - return %0 : tensor<4x3x2xi32> -} - -// ----- - -// Check multiple dimensions have size 1 -// CHECK-LABEL: @broadcast_tensor_tensor_tensor -func @broadcast_tensor_tensor_tensor(tensor<8x1x6x1xi32>, tensor<7x1x5xi32>) -> tensor<8x7x6x5xi32> { -^bb0(%arg0: tensor<8x1x6x1xi32>, %arg1: tensor<7x1x5xi32>): - // CHECK: %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "Relu6"} : (tensor<8x1x6x1xi32>, tensor<7x1x5xi32>) -> tensor<8x7x6x5xi32> - %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "Relu6"} : (tensor<8x1x6x1xi32>, tensor<7x1x5xi32>) -> tensor<8x7x6x5xi32> - return %0 : tensor<8x7x6x5xi32> -} - -// ----- - -// Check leading unknown dimension -// CHECK-LABEL: @broadcast_tensor_tensor_tensor -func @broadcast_tensor_tensor_tensor(tensor, tensor<7x1x5xi32>) -> tensor { -^bb0(%arg0: tensor, %arg1: tensor<7x1x5xi32>): - // CHECK: %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "Relu6"} : (tensor, tensor<7x1x5xi32>) -> tensor - %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "Relu6"} : (tensor, tensor<7x1x5xi32>) -> tensor - return %0 : tensor -} - -// ----- - -// Check unknown dimension in the middle -// CHECK-LABEL: @broadcast_tensor_tensor_tensor -func @broadcast_tensor_tensor_tensor(tensor<8x1x?x1xi32>, tensor<7x1x5xi32>) -> tensor<8x7x?x5xi32> { -^bb0(%arg0: tensor<8x1x?x1xi32>, %arg1: tensor<7x1x5xi32>): - // CHECK: %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "Relu6"} : (tensor<8x1x?x1xi32>, tensor<7x1x5xi32>) -> tensor<8x7x?x5xi32> - %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "Relu6"} : (tensor<8x1x?x1xi32>, tensor<7x1x5xi32>) -> tensor<8x7x?x5xi32> - return %0 : tensor<8x7x?x5xi32> -} - -// ----- - -// Check incompatible operand types with scalar types -func @broadcast_scalar_scalar_scalar(tensor, tensor) -> tensor { -^bb0(%arg0: tensor, %arg1: tensor): - // expected-error @+1 {{operands don't have broadcast-compatible types}} - %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "RELU6"} : (tensor, tensor) -> tensor - return %0 : tensor -} - -// ----- - -// Check incompatible operand types with scalar types -func @broadcast_scalar_vector_vector(tensor, tensor>) -> tensor> { -^bb0(%arg0: tensor, %arg1: tensor>): - // expected-error @+1 {{operands don't have broadcast-compatible types}} - %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "Relu6"} : (tensor, tensor>) -> tensor> - return %0 : tensor> -} - -// ----- - -// Check incompatible vector and tensor operand types -func @broadcast_scalar_vector_vector(tensor<4xf32>, tensor>) -> tensor> { -^bb0(%arg0: tensor<4xf32>, %arg1: tensor>): - // expected-error @+1 {{operands don't have broadcast-compatible types}} - %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "Relu6"} : (tensor<4xf32>, tensor>) -> tensor> - return %0 : tensor> -} - -// ----- - -// Check incompatible vector and tensor result type -func @broadcast_scalar_vector_vector(tensor<4xf32>, tensor<4xf32>) -> vector<4xf32> { -^bb0(%arg0: tensor<4xf32>, %arg1: tensor<4xf32>): - // expected-error @+1 {{does not have the same shape as the broadcasted type}} - %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "Relu6"} : (tensor<4xf32>, tensor<4xf32>) -> vector<4xf32> - return %0 : vector<4xf32> -} - -// ----- - -// Check incompatible operand types with known dimension -func @broadcast_tensor_tensor_tensor(tensor<4x3x2xi32>, tensor<3x3xi32>) -> tensor<4x3x2xi32> { -^bb0(%arg0: tensor<4x3x2xi32>, %arg1: tensor<3x3xi32>): - // expected-error @+1 {{operands don't have broadcast-compatible types}} - %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "RELU6"} : (tensor<4x3x2xi32>, tensor<3x3xi32>) -> tensor<4x3x2xi32> - return %0 : tensor<4x3x2xi32> -} - -// ----- - -// Check incompatible result type with known dimension -func @broadcast_tensor_tensor_tensor(tensor<4x3x2xi32>, tensor<3x1xi32>) -> tensor<4x3x3xi32> { -^bb0(%arg0: tensor<4x3x2xi32>, %arg1: tensor<3x1xi32>): - // expected-error @+1 {{does not have the same shape as the broadcasted type}} - %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "RELU6"} : (tensor<4x3x2xi32>, tensor<3x1xi32>) -> tensor<4x3x3xi32> - return %0 : tensor<4x3x3xi32> -} - -// ----- - -// Check incompatible result type with known dimension -func @broadcast_tensor_tensor_tensor(tensor<8x1x6x1xi32>, tensor<7x1x5xi32>) -> tensor<8x7x6x1xi32> { -^bb0(%arg0: tensor<8x1x6x1xi32>, %arg1: tensor<7x1x5xi32>): - // expected-error @+1 {{does not have the same shape as the broadcasted type}} - %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "Relu6"} : (tensor<8x1x6x1xi32>, tensor<7x1x5xi32>) -> tensor<8x7x6x1xi32> - return %0 : tensor<8x7x6x1xi32> -} - -// ----- - -func @broadcast_tensor_tensor_tensor(tensor<4x3x2xi32>, tensor) -> tensor<4x3x2xi32> { -^bb0(%arg0: tensor<4x3x2xi32>, %arg1: tensor): - // CHECK: %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "RELU6"} : (tensor<4x3x2xi32>, tensor) -> tensor<4x3x2xi32> - %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "RELU6"} : (tensor<4x3x2xi32>, tensor) -> tensor<4x3x2xi32> - return %0 : tensor<4x3x2xi32> -} - -// ----- - -// Check incompatible result type with unknown dimension -func @broadcast_tensor_tensor_tensor(tensor, tensor<7x1x5xi32>) -> tensor<8x7x6x5xi32> { -^bb0(%arg0: tensor, %arg1: tensor<7x1x5xi32>): - // expected-error @+1 {{does not have the same shape as the broadcasted type}} - %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "Relu6"} : (tensor, tensor<7x1x5xi32>) -> tensor<8x7x6x5xi32> - return %0 : tensor<8x7x6x5xi32> -} - -// ----- - -// Check tensor of vector -func @broadcast_tensor_tensor_tensor(tensor>, tensor>) -> tensor> { -^bb0(%arg0: tensor>, %arg1: tensor>): - // expected-error @+1 {{operands don't have broadcast-compatible types}} - %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "RELU6"} : (tensor>, tensor>) -> tensor> - return %0 : tensor> -} - -// ----- - -// Check unranked types -func @broadcast_tensor_tensor_tensor(tensor<4x3x2xi32>, tensor<*xi32>) -> tensor<*xi32> { -^bb0(%arg0: tensor<4x3x2xi32>, %arg1: tensor<*xi32>): - %0 = "tf.Add"(%arg0, %arg1) : (tensor<4x3x2xi32>, tensor<*xi32>) -> tensor<*xi32> - return %0 : tensor<*xi32> -} - -// ----- - -// Check unranked operand but ranked result -func @broadcast_tensor_tensor_tensor(tensor<4x3x2xi32>, tensor<*xi32>) -> tensor<4x3x2xi32> { -^bb0(%arg0: tensor<4x3x2xi32>, %arg1: tensor<*xi32>): - // expected-error @+1 {{does not have the same shape as the broadcasted type}} - %0 = "tfl.add"(%arg0, %arg1) {fused_activation_function: "RELU6"} : (tensor<4x3x2xi32>, tensor<*xi32>) -> tensor<4x3x2xi32> - return %0 : tensor<4x3x2xi32> -} - -// ----- - -// Check different input and output element types -func @broadcast_cmp_op(tensor<4xi32>, tensor<4xi32>) -> tensor<4xi1> { -^bb0(%arg0: tensor<4xi32>, %arg1: tensor<4xi32>): - // CHECK: %0 = "tf.Less"(%arg0, %arg1) : (tensor<4xi32>, tensor<4xi32>) -> tensor<4xi1> - %0 = "tf.Less"(%arg0, %arg1) : (tensor<4xi32>, tensor<4xi32>) -> tensor<4xi1> - return %0 : tensor<4xi1> -} - -// ----- - -// Check unranked operand and result with different element types -func @broadcast_cmp_op(tensor<*xi32>, tensor) -> tensor<*xi1> { -^bb0(%arg0: tensor<*xi32>, %arg1: tensor): - // CHECK: %0 = "tf.Less"(%arg0, %arg1) : (tensor<*xi32>, tensor) -> tensor<*xi1> - %0 = "tf.Less"(%arg0, %arg1) : (tensor<*xi32>, tensor) -> tensor<*xi1> - return %0 : tensor<*xi1> -} -- 2.7.4