Fixing bug in Vulkan HAL that was not handling binding offsets. (#3517)
diff --git a/integrations/tensorflow/e2e/keras/BUILD b/integrations/tensorflow/e2e/keras/BUILD
index 0643127..f93e9d1 100644
--- a/integrations/tensorflow/e2e/keras/BUILD
+++ b/integrations/tensorflow/e2e/keras/BUILD
@@ -173,8 +173,7 @@
# All models with runtime shorter than ResNet50.
"MobileNet", # Max: Vulkan 61.0s
"MobileNetV2", # Max: LLVM 96.3s
- # TODO(#3489): started having vulkan diffs after #3424; investigate.
- # "ResNet50", # Max: LLVM 145.6s
+ "ResNet50", # Max: LLVM 145.6s
"VGG16", # Max: LLVM 89.5s
"VGG19", # Max: LLVM 94.7s
],
diff --git a/iree/hal/vulkan/api.cc b/iree/hal/vulkan/api.cc
index fe6761f..acba36d 100644
--- a/iree/hal/vulkan/api.cc
+++ b/iree/hal/vulkan/api.cc
@@ -89,7 +89,7 @@
VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
if (features & IREE_HAL_VULKAN_ENABLE_VALIDATION_LAYERS) {
- spec.optional_layers.push_back("VK_LAYER_LUNARG_standard_validation");
+ spec.optional_layers.push_back("VK_LAYER_KHRONOS_standard_validation");
}
if (features & IREE_HAL_VULKAN_ENABLE_DEBUG_UTILS) {
diff --git a/iree/hal/vulkan/api.h b/iree/hal/vulkan/api.h
index 482a85d..c3abe0c 100644
--- a/iree/hal/vulkan/api.h
+++ b/iree/hal/vulkan/api.h
@@ -48,7 +48,7 @@
// Bitfield that defines sets of Vulkan features.
typedef enum {
- // Use VK_LAYER_LUNARG_standard_validation.
+ // Use VK_LAYER_KHRONOS_standard_validation.
IREE_HAL_VULKAN_ENABLE_VALIDATION_LAYERS = 1 << 0,
// Use VK_EXT_debug_utils, record markers, and log errors.
diff --git a/iree/hal/vulkan/descriptor_set_arena.cc b/iree/hal/vulkan/descriptor_set_arena.cc
index f548400..97b8b86 100644
--- a/iree/hal/vulkan/descriptor_set_arena.cc
+++ b/iree/hal/vulkan/descriptor_set_arena.cc
@@ -46,8 +46,7 @@
auto& buffer_info = buffer_infos[i];
IREE_ASSIGN_OR_RETURN(auto buffer, CastBuffer(binding.buffer));
buffer_info.buffer = buffer->handle();
- // TODO(benvanik): properly subrange (add to BufferBinding).
- buffer_info.offset = binding.buffer->byte_offset();
+ buffer_info.offset = binding.buffer->byte_offset() + binding.offset;
// Round up to a multiple of 32-bit. 32-bit is the most native bitwidth on
// GPUs; it has the best support compared to other bitwidths. We use VMA to
// manage GPU memory for us and VMA should already handled proper alignment
@@ -65,7 +64,10 @@
// the shader is considered as out of bounds per the Vulkan spec.
// See https://github.com/google/iree/issues/2022#issuecomment-640617234
// for more details.
- buffer_info.range = iree_align(binding.buffer->byte_length(), 4);
+ buffer_info.range =
+ iree_align(std::min(binding.length,
+ binding.buffer->byte_length() - binding.offset),
+ 4);
auto& write_info = write_infos[i];
write_info.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
diff --git a/iree/hal/vulkan/vulkan_driver_module.cc b/iree/hal/vulkan/vulkan_driver_module.cc
index 8f42e17..f9418c9 100644
--- a/iree/hal/vulkan/vulkan_driver_module.cc
+++ b/iree/hal/vulkan/vulkan_driver_module.cc
@@ -78,7 +78,7 @@
if (absl::GetFlag(FLAGS_vulkan_validation_layers)) {
options.instance_extensibility.optional_layers.push_back(
- "VK_LAYER_LUNARG_standard_validation");
+ "VK_LAYER_KHRONOS_validation");
}
if (absl::GetFlag(FLAGS_vulkan_debug_report)) {