-
Notifications
You must be signed in to change notification settings - Fork 603
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add f16 e2e tests for vulkan (#5257)
- Loading branch information
1 parent
1bdc3a4
commit 10f5eaf
Showing
8 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright 2021 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Tests of end-to-end IREE support for support of specific subsets of ops in the | ||
# XLA HLO dialect. This is for cases where some variation (e.g. tensor element | ||
# types) of an op is not supported on all backends. When the test is supported | ||
# on all backends it should be moved into the corresponding op test in the main | ||
# xla_ops direcotry. Each test file should have a name matching the | ||
# corresponding XLA HLO op with a suffix indicating the subset it tests. Only | ||
# the functionality of that op should be tessted (though it may make use of | ||
# other ops where necessary). Tests should be written using the IREE Check | ||
# framework and should always pass on the reference VMLA backend. See | ||
# https://google.github.io/iree/TestingGuide#iree-core-end-to-end-tests. | ||
|
||
load("//build_tools/bazel:iree_check_test.bzl", "iree_check_single_backend_test_suite") | ||
|
||
package( | ||
default_visibility = ["//visibility:public"], | ||
features = ["layering_check"], | ||
licenses = ["notice"], # Apache 2.0 | ||
) | ||
|
||
iree_check_single_backend_test_suite( | ||
name = "check_linalg_on_tensors_vulkan-spirv_vulkan_f16", | ||
srcs = [ | ||
"add_f16.mlir", | ||
"dot_f16.mlir", | ||
], | ||
compiler_flags = [ | ||
"-iree-flow-dispatch-linalg-on-tensors", | ||
"-iree-codegen-spirv-experimental-linalg-on-tensors", | ||
"-iree-vulkan-target-triple=valhall-g77-unknown-android10", | ||
], | ||
driver = "vulkan", | ||
tags = [ | ||
"notap", | ||
"vulkan_uses_vk_khr_shader_float16_int8", | ||
], | ||
target_backend = "vulkan-spirv", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
################################################################################ | ||
# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from # | ||
# iree/test/e2e/xla_ops/partial/BUILD # | ||
# # | ||
# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary # | ||
# CMake-only content. # | ||
# # | ||
# To disable autogeneration for this file entirely, delete this header. # | ||
################################################################################ | ||
|
||
iree_add_all_subdirs() | ||
|
||
iree_check_single_backend_test_suite( | ||
NAME | ||
check_linalg_on_tensors_vulkan-spirv_vulkan_f16 | ||
SRCS | ||
"add_f16.mlir" | ||
"dot_f16.mlir" | ||
TARGET_BACKEND | ||
"vulkan-spirv" | ||
DRIVER | ||
"vulkan" | ||
COMPILER_FLAGS | ||
"-iree-flow-dispatch-linalg-on-tensors" | ||
"-iree-codegen-spirv-experimental-linalg-on-tensors" | ||
"-iree-vulkan-target-triple=valhall-g77-unknown-android10" | ||
LABELS | ||
"notap" | ||
"vulkan_uses_vk_khr_shader_float16_int8" | ||
) | ||
|
||
### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
func @add_f16() attributes { iree.module.export } { | ||
%0 = iree.unfoldable_constant dense<[1.5, 2.0, 3.0, 4.2]> : tensor<4xf16> | ||
%1 = iree.unfoldable_constant dense<[5.0, 6.2, 7.0, 8.1]> : tensor<4xf16> | ||
%result = "mhlo.add"(%0, %1) : (tensor<4xf16>, tensor<4xf16>) -> tensor<4xf16> | ||
check.expect_almost_eq_const(%result, dense<[6.5, 8.2, 10.0, 12.3]> : tensor<4xf16>) : tensor<4xf16> | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
func @f16() attributes { iree.module.export } { | ||
%lhs = iree.unfoldable_constant dense<[ | ||
[15.0, 14.0, 13.0], | ||
[12.0, 11.0, 10.0], | ||
[09.0, 08.0, 07.0], | ||
[06.0, 05.0, 04.0], | ||
[03.0, 02.0, 01.0]]> : tensor<5x3xf16> | ||
%rhs = iree.unfoldable_constant dense<[ | ||
[15.0, 14.0, 13.0, 12.0, 11.0], | ||
[10.0, 09.0, 08.0, 07.0, 06.0], | ||
[05.0, 04.0, 03.0, 02.0, 01.0]]> : tensor<3x5xf16> | ||
%res = "mhlo.dot"(%lhs, %rhs) : (tensor<5x3xf16>, tensor<3x5xf16>) -> tensor<5x5xf16> | ||
check.expect_almost_eq_const(%res, dense<[ | ||
[430.0, 388.0, 346.0, 304.0, 262.0], | ||
[340.0, 307.0, 274.0, 241.0, 208.0], | ||
[250.0, 226.0, 202.0, 178.0, 154.0], | ||
[160.0, 145.0, 130.0, 115.0, 100.0], | ||
[70.0, 64.0, 58.0, 52.0, 46.0]]> : tensor<5x5xf16>) : tensor<5x5xf16> | ||
return | ||
} |