[spirv] NFC: clean up (de)serialization tests

This CL uses the newly added -split-input-file CLI option to
mlir-translate to combine certain (de)serialization tests.
It also renames certain test filenames.

PiperOrigin-RevId: 270816324
This commit is contained in:
Lei Zhang 2019-09-23 19:56:49 -07:00 committed by A. Unique TensorFlower
parent 69af468754
commit 6caa4f500b
21 changed files with 179 additions and 167 deletions

View file

@ -71,54 +71,4 @@ spv.module "Logical" "GLSL450" {
%0 = spv.SRem %arg0, %arg1 : vector<4xi32>
spv.Return
}
func @iequal_scalar(%arg0: i32, %arg1: i32) {
// CHECK: {{.*}} = spv.IEqual {{.*}}, {{.*}} : i32
%0 = spv.IEqual %arg0, %arg1 : i32
spv.Return
}
func @inotequal_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
// CHECK: {{.*}} = spv.INotEqual {{.*}}, {{.*}} : vector<4xi32>
%0 = spv.INotEqual %arg0, %arg1 : vector<4xi32>
spv.Return
}
func @sgt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
// CHECK: {{.*}} = spv.SGreaterThan {{.*}}, {{.*}} : vector<4xi32>
%0 = spv.SGreaterThan %arg0, %arg1 : vector<4xi32>
spv.Return
}
func @sge_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
// CHECK: {{.*}} = spv.SGreaterThanEqual {{.*}}, {{.*}} : vector<4xi32>
%0 = spv.SGreaterThanEqual %arg0, %arg1 : vector<4xi32>
spv.Return
}
func @slt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
// CHECK: {{.*}} = spv.SLessThan {{.*}}, {{.*}} : vector<4xi32>
%0 = spv.SLessThan %arg0, %arg1 : vector<4xi32>
spv.Return
}
func @slte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
// CHECK: {{.*}} = spv.SLessThanEqual {{.*}}, {{.*}} : vector<4xi32>
%0 = spv.SLessThanEqual %arg0, %arg1 : vector<4xi32>
spv.Return
}
func @ugt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
// CHECK: {{.*}} = spv.UGreaterThan {{.*}}, {{.*}} : vector<4xi32>
%0 = spv.UGreaterThan %arg0, %arg1 : vector<4xi32>
spv.Return
}
func @ugte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
// CHECK: {{.*}} = spv.UGreaterThanEqual {{.*}}, {{.*}} : vector<4xi32>
%0 = spv.UGreaterThanEqual %arg0, %arg1 : vector<4xi32>
spv.Return
}
func @ult_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
// CHECK: {{.*}} = spv.ULessThan {{.*}}, {{.*}} : vector<4xi32>
%0 = spv.ULessThan %arg0, %arg1 : vector<4xi32>
spv.Return
}
func @ulte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
// CHECK: {{.*}} = spv.ULessThanEqual {{.*}}, {{.*}} : vector<4xi32>
%0 = spv.ULessThanEqual %arg0, %arg1 : vector<4xi32>
spv.Return
}
}

View file

@ -1,4 +1,4 @@
// RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s
// RUN: mlir-translate -split-input-file -test-spirv-roundtrip %s | FileCheck %s
spv.module "Logical" "GLSL450" {
func @array_stride(%arg0 : !spv.ptr<!spv.array<4x!spv.array<4xf32 [4]> [128]>, StorageBuffer>,
@ -8,3 +8,12 @@ spv.module "Logical" "GLSL450" {
spv.Return
}
}
// -----
spv.module "Logical" "GLSL450" {
// CHECK: spv.globalVariable {{@.*}} : !spv.ptr<!spv.rtarray<f32>, StorageBuffer>
spv.globalVariable @var0 : !spv.ptr<!spv.rtarray<f32>, StorageBuffer>
// CHECK: spv.globalVariable {{@.*}} : !spv.ptr<!spv.rtarray<vector<4xf16>>, Input>
spv.globalVariable @var1 : !spv.ptr<!spv.rtarray<vector<4xf16>>, Input>
}

View file

@ -1,7 +0,0 @@
// RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s
spv.module "Logical" "GLSL450" {
} attributes {
// CHECK: capabilities = ["Shader", "Float16"]
capabilities = ["Shader", "Float16"]
}

View file

@ -1,4 +1,16 @@
// RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s
// RUN: mlir-translate -test-spirv-roundtrip -split-input-file %s | FileCheck %s
spv.module "Logical" "GLSL450" {
func @noop() -> () {
spv.Return
}
// CHECK: spv.EntryPoint "GLCompute" @noop
// CHECK-NEXT: spv.ExecutionMode @noop "ContractionOff"
spv.EntryPoint "GLCompute" @noop
spv.ExecutionMode @noop "ContractionOff"
}
// -----
spv.module "Logical" "GLSL450" {
// CHECK: spv.globalVariable @var2 : !spv.ptr<f32, Input>

View file

@ -1,11 +0,0 @@
// RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s
spv.module "Logical" "GLSL450" {
func @noop() -> () {
spv.Return
}
// CHECK: spv.EntryPoint "GLCompute" @noop
// CHECK-NEXT: spv.ExecutionMode @noop "ContractionOff"
spv.EntryPoint "GLCompute" @noop
spv.ExecutionMode @noop "ContractionOff"
}

View file

@ -1,8 +0,0 @@
// RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s
spv.module "Logical" "GLSL450" {
} attributes {
// CHECK: extensions = ["SPV_KHR_float_controls", "SPV_KHR_subgroup_vote"]
extensions = ["SPV_KHR_float_controls", "SPV_KHR_subgroup_vote"]
}

View file

@ -0,0 +1,36 @@
// RUN: mlir-translate -test-spirv-roundtrip -split-input-file %s | FileCheck %s
// CHECK: spv.globalVariable @var0 bind(1, 0) : !spv.ptr<f32, Input>
// CHECK-NEXT: spv.globalVariable @var1 bind(0, 1) : !spv.ptr<f32, Output>
// CHECK-NEXT: spv.globalVariable @var2 built_in("GlobalInvocationId") : !spv.ptr<vector<3xi32>, Input>
// CHECK-NEXT: spv.globalVariable @var3 built_in("GlobalInvocationId") : !spv.ptr<vector<3xi32>, Input>
spv.module "Logical" "GLSL450" {
spv.globalVariable @var0 bind(1, 0) : !spv.ptr<f32, Input>
spv.globalVariable @var1 bind(0, 1) : !spv.ptr<f32, Output>
spv.globalVariable @var2 {built_in = "GlobalInvocationId"} : !spv.ptr<vector<3xi32>, Input>
spv.globalVariable @var3 built_in("GlobalInvocationId") : !spv.ptr<vector<3xi32>, Input>
}
// -----
spv.module "Logical" "GLSL450" {
// CHECK: spv.globalVariable @var1 : !spv.ptr<f32, Input>
// CHECK-NEXT: spv.globalVariable @var2 initializer(@var1) bind(1, 0) : !spv.ptr<f32, Input>
spv.globalVariable @var1 : !spv.ptr<f32, Input>
spv.globalVariable @var2 initializer(@var1) bind(1, 0) : !spv.ptr<f32, Input>
}
// -----
spv.module "Logical" "GLSL450" {
spv.globalVariable @globalInvocationID built_in("GlobalInvocationId") : !spv.ptr<vector<3xi32>, Input>
func @foo() {
// CHECK: %[[ADDR:.*]] = spv._address_of @globalInvocationID : !spv.ptr<vector<3xi32>, Input>
%0 = spv._address_of @globalInvocationID : !spv.ptr<vector<3xi32>, Input>
%1 = spv.constant 0: i32
// CHECK: spv.AccessChain %[[ADDR]]
%2 = spv.AccessChain %0[%1] : !spv.ptr<vector<3xi32>, Input>
spv.Return
}
}

View file

@ -1,13 +0,0 @@
// RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s
// CHECK: func {{@.*}}([[ARG1:%.*]]: !spv.ptr<f32, Input>, [[ARG2:%.*]]: !spv.ptr<f32, Output>) {
// CHECK-NEXT: [[VALUE:%.*]] = spv.Load "Input" [[ARG1]] : f32
// CHECK-NEXT: spv.Store "Output" [[ARG2]], [[VALUE]] : f32
spv.module "Logical" "GLSL450" {
func @load_store(%arg0 : !spv.ptr<f32, Input>, %arg1 : !spv.ptr<f32, Output>) {
%1 = spv.Load "Input" %arg0 : f32
spv.Store "Output" %arg1, %1 : f32
spv.Return
}
}

View file

@ -0,0 +1,75 @@
// RUN: mlir-translate -split-input-file -test-spirv-roundtrip %s | FileCheck %s
spv.module "Logical" "GLSL450" {
func @iequal_scalar(%arg0: i32, %arg1: i32) {
// CHECK: {{.*}} = spv.IEqual {{.*}}, {{.*}} : i32
%0 = spv.IEqual %arg0, %arg1 : i32
spv.Return
}
func @inotequal_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
// CHECK: {{.*}} = spv.INotEqual {{.*}}, {{.*}} : vector<4xi32>
%0 = spv.INotEqual %arg0, %arg1 : vector<4xi32>
spv.Return
}
func @sgt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
// CHECK: {{.*}} = spv.SGreaterThan {{.*}}, {{.*}} : vector<4xi32>
%0 = spv.SGreaterThan %arg0, %arg1 : vector<4xi32>
spv.Return
}
func @sge_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
// CHECK: {{.*}} = spv.SGreaterThanEqual {{.*}}, {{.*}} : vector<4xi32>
%0 = spv.SGreaterThanEqual %arg0, %arg1 : vector<4xi32>
spv.Return
}
func @slt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
// CHECK: {{.*}} = spv.SLessThan {{.*}}, {{.*}} : vector<4xi32>
%0 = spv.SLessThan %arg0, %arg1 : vector<4xi32>
spv.Return
}
func @slte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
// CHECK: {{.*}} = spv.SLessThanEqual {{.*}}, {{.*}} : vector<4xi32>
%0 = spv.SLessThanEqual %arg0, %arg1 : vector<4xi32>
spv.Return
}
func @ugt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
// CHECK: {{.*}} = spv.UGreaterThan {{.*}}, {{.*}} : vector<4xi32>
%0 = spv.UGreaterThan %arg0, %arg1 : vector<4xi32>
spv.Return
}
func @ugte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
// CHECK: {{.*}} = spv.UGreaterThanEqual {{.*}}, {{.*}} : vector<4xi32>
%0 = spv.UGreaterThanEqual %arg0, %arg1 : vector<4xi32>
spv.Return
}
func @ult_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
// CHECK: {{.*}} = spv.ULessThan {{.*}}, {{.*}} : vector<4xi32>
%0 = spv.ULessThan %arg0, %arg1 : vector<4xi32>
spv.Return
}
func @ulte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
// CHECK: {{.*}} = spv.ULessThanEqual {{.*}}, {{.*}} : vector<4xi32>
%0 = spv.ULessThanEqual %arg0, %arg1 : vector<4xi32>
spv.Return
}
}
// -----
spv.module "Logical" "GLSL450" {
spv.specConstant @condition_scalar = true
func @select() -> () {
%0 = spv.constant 4.0 : f32
%1 = spv.constant 5.0 : f32
%2 = spv._reference_of @condition_scalar : i1
// CHECK: spv.Select {{.*}}, {{.*}}, {{.*}} : i1, f32
%3 = spv.Select %2, %0, %1 : i1, f32
%4 = spv.constant dense<[2.0, 3.0, 4.0, 5.0]> : vector<4xf32>
%5 = spv.constant dense<[6.0, 7.0, 8.0, 9.0]> : vector<4xf32>
// CHECK: spv.Select {{.*}}, {{.*}}, {{.*}} : i1, vector<4xf32>
%6 = spv.Select %2, %4, %5 : i1, vector<4xf32>
%7 = spv.constant dense<[true, true, true, true]> : vector<4xi1>
// CHECK: spv.Select {{.*}}, {{.*}}, {{.*}} : vector<4xi1>, vector<4xf32>
%8 = spv.Select %7, %4, %5 : vector<4xi1>, vector<4xf32>
spv.Return
}
}

View file

@ -1,4 +1,18 @@
// RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s
// RUN: mlir-translate -test-spirv-roundtrip -split-input-file %s | FileCheck %s
// CHECK: func {{@.*}}([[ARG1:%.*]]: !spv.ptr<f32, Input>, [[ARG2:%.*]]: !spv.ptr<f32, Output>) {
// CHECK-NEXT: [[VALUE:%.*]] = spv.Load "Input" [[ARG1]] : f32
// CHECK-NEXT: spv.Store "Output" [[ARG2]], [[VALUE]] : f32
spv.module "Logical" "GLSL450" {
func @load_store(%arg0 : !spv.ptr<f32, Input>, %arg1 : !spv.ptr<f32, Output>) {
%1 = spv.Load "Input" %arg0 : f32
spv.Store "Output" %arg1, %1 : f32
spv.Return
}
}
// -----
spv.module "Logical" "GLSL450" {
func @access_chain(%arg0 : !spv.ptr<!spv.array<4x!spv.array<4xf32>>, Function>,

View file

@ -1,13 +0,0 @@
// RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s
// CHECK: spv.module "Logical" "GLSL450" {
// CHECK-NEXT: func @foo() {
// CHECK-NEXT: spv.Return
// CHECK-NEXT: }
// CHECK-NEXT: } attributes {major_version = 1 : i32, minor_version = 0 : i32}
spv.module "Logical" "GLSL450" {
func @foo() -> () {
spv.Return
}
}

View file

@ -0,0 +1,30 @@
// RUN: mlir-translate -test-spirv-roundtrip -split-input-file %s | FileCheck %s
// CHECK: spv.module "Logical" "GLSL450" {
// CHECK-NEXT: func @foo() {
// CHECK-NEXT: spv.Return
// CHECK-NEXT: }
// CHECK-NEXT: } attributes {major_version = 1 : i32, minor_version = 0 : i32}
spv.module "Logical" "GLSL450" {
func @foo() -> () {
spv.Return
}
}
// -----
spv.module "Logical" "GLSL450" {
} attributes {
// CHECK: capabilities = ["Shader", "Float16"]
capabilities = ["Shader", "Float16"]
}
// -----
spv.module "Logical" "GLSL450" {
} attributes {
// CHECK: extensions = ["SPV_KHR_float_controls", "SPV_KHR_subgroup_vote"]
extensions = ["SPV_KHR_float_controls", "SPV_KHR_subgroup_vote"]
}

View file

@ -1,8 +0,0 @@
// RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s
spv.module "Logical" "GLSL450" {
// CHECK: spv.globalVariable {{@.*}} : !spv.ptr<!spv.rtarray<f32>, StorageBuffer>
spv.globalVariable @var0 : !spv.ptr<!spv.rtarray<f32>, StorageBuffer>
// CHECK: spv.globalVariable {{@.*}} : !spv.ptr<!spv.rtarray<vector<4xf16>>, Input>
spv.globalVariable @var1 : !spv.ptr<!spv.rtarray<vector<4xf16>>, Input>
}

View file

@ -1,20 +0,0 @@
// RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s
spv.module "Logical" "GLSL450" {
spv.specConstant @condition_scalar = true
func @select() -> () {
%0 = spv.constant 4.0 : f32
%1 = spv.constant 5.0 : f32
%2 = spv._reference_of @condition_scalar : i1
// CHECK: spv.Select {{.*}}, {{.*}}, {{.*}} : i1, f32
%3 = spv.Select %2, %0, %1 : i1, f32
%4 = spv.constant dense<[2.0, 3.0, 4.0, 5.0]> : vector<4xf32>
%5 = spv.constant dense<[6.0, 7.0, 8.0, 9.0]> : vector<4xf32>
// CHECK: spv.Select {{.*}}, {{.*}}, {{.*}} : i1, vector<4xf32>
%6 = spv.Select %2, %4, %5 : i1, vector<4xf32>
%7 = spv.constant dense<[true, true, true, true]> : vector<4xi1>
// CHECK: spv.Select {{.*}}, {{.*}}, {{.*}} : vector<4xi1>, vector<4xf32>
%8 = spv.Select %7, %4, %5 : vector<4xi1>, vector<4xf32>
spv.Return
}
}

View file

@ -1,13 +0,0 @@
// RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s
spv.module "Logical" "GLSL450" {
spv.globalVariable @globalInvocationID built_in("GlobalInvocationId") : !spv.ptr<vector<3xi32>, Input>
func @foo() {
// CHECK: %[[ADDR:.*]] = spv._address_of @globalInvocationID : !spv.ptr<vector<3xi32>, Input>
%0 = spv._address_of @globalInvocationID : !spv.ptr<vector<3xi32>, Input>
%1 = spv.constant 0: i32
// CHECK: spv.AccessChain %[[ADDR]]
%2 = spv.AccessChain %0[%1] : !spv.ptr<vector<3xi32>, Input>
spv.Return
}
}

View file

@ -1,13 +0,0 @@
// RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s
// CHECK: spv.globalVariable @var0 bind(1, 0) : !spv.ptr<f32, Input>
// CHECK-NEXT: spv.globalVariable @var1 bind(0, 1) : !spv.ptr<f32, Output>
// CHECK-NEXT: spv.globalVariable @var2 built_in("GlobalInvocationId") : !spv.ptr<vector<3xi32>, Input>
// CHECK-NEXT: spv.globalVariable @var3 built_in("GlobalInvocationId") : !spv.ptr<vector<3xi32>, Input>
spv.module "Logical" "GLSL450" {
spv.globalVariable @var0 bind(1, 0) : !spv.ptr<f32, Input>
spv.globalVariable @var1 bind(0, 1) : !spv.ptr<f32, Output>
spv.globalVariable @var2 {built_in = "GlobalInvocationId"} : !spv.ptr<vector<3xi32>, Input>
spv.globalVariable @var3 built_in("GlobalInvocationId") : !spv.ptr<vector<3xi32>, Input>
}

View file

@ -1,8 +0,0 @@
// RUN: mlir-translate -test-spirv-roundtrip %s | FileCheck %s
spv.module "Logical" "GLSL450" {
// CHECK: spv.globalVariable @var1 : !spv.ptr<f32, Input>
// CHECK-NEXT: spv.globalVariable @var2 initializer(@var1) bind(1, 0) : !spv.ptr<f32, Input>
spv.globalVariable @var1 : !spv.ptr<f32, Input>
spv.globalVariable @var2 initializer(@var1) bind(1, 0) : !spv.ptr<f32, Input>
}