Skip to content

Commit f892c30

Browse files
author
ssjia
committed
Update on "[ET-VK] Miscellaneous fixes"
Collecting fixes for various models/ops in this diff/PR. They have all been squashed into this single change to make it easier to cherry pick. # Fixes ## Wav2Letter Type: Output correctness failure This is caused by a bug in swiftshader, and not reproducible on any other platform. Specifically, the issue is in the softmax shader; the exact cause of the issue is unknown, but it is related to using shared memory within shaders. The workaround for this issue is to use separate shared memory arrays for the shared max and shared sum. ## ConvNeXT Type: Exception during runtime This is caused by an incompatible memory layout being used for mean2d. More technically, the packed dimension of the tensor cannot be one of the dims being reduced. The current operator registry system did not have a way to select valid tensor representations based on the actual arguments of an op. To fix, we have to introduce a mechanism for ops to specify valid representations once a node's arguments are known. Once the model is exported with supported memory layout, the model test passes. ## Inception_V3/ViT Type: Exception during runtime The root cause of this was an interaction betwen the fuse batch norm pass and how `vulkan_preprocess.py` was applying passes. Essentially, the fuse batch norm pass creates a new param node for the fused weight, but after the pass is applied `_copy_module` is used to copy the transformed graph back into the ExportedProgram. However, it seems that _copy_module lowercases the node names without updating the exported program's graph signature. Therefore, subsequent passes couldn't recognize the weight tensor of convolution tensors as a constant/parameter node. The solution was to migrate vulkan_preprocess.py to use the _transform() API instead of using _copy_module. ## DenseNet 161 (w/ dynamic shapes) Type: Output Mismatch Cause: the native_batch_norm op doesn't support dynamic shapes. However, the backend test runner doesn't set the correct compile option to filter ops without dynamic shape support. Differential Revision: [D83703496](https://our.internmc.facebook.com/intern/diff/D83703496/) [ghstack-poisoned]
2 parents 668de3c + 8503fa1 commit f892c30

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

.github/workflows/pull.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ jobs:
976976
done
977977
978978
# For selected vision models, test with dynamic shapes
979-
models="mv2 mv3 resnet18 resnet50 ic3 ic4 densenet161"
979+
models="mv2 resnet18 resnet50 ic3 densenet161"
980980
for model in $models; do
981981
python -m examples.vulkan.export --model_name=$model --test -d
982982
done

backends/vulkan/runtime/graph/ops/glsl/conv2d.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void main() {
6060
int num_steps = ((-ipos.y) + dilation.y - 1) / dilation.y;
6161
start.y = ipos.y + num_steps * dilation.y;
6262
}
63-
const ivec2 end = min(ipos + overlay_region.xy, ivec2(in_sizes.xy));
63+
const ivec2 end = min(ipos + overlay_region.xy, in_sizes.xy);
6464
// Compute the start of the kernel based on how far we are skipping ahead when
6565
// reading the input. Note that these are "canonical" indices.
6666
ivec2 kstart = (start - ipos) / dilation;

backends/vulkan/runtime/graph/ops/glsl/conv2d_dw.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void main() {
5454
// Compute the start and end of the input indices to load. Padding is assumed
5555
// to be constant 0 padding, so reads from the padding region are skipped.
5656
const ivec2 start = ipos;
57-
const ivec2 end = ipos + overlay_region.xy;
57+
const ivec2 end = min(ipos + overlay_region.xy, in_sizes.xy);
5858

5959
VEC4_T sum = texelFetch(t_bias, ivec2(pos.z, 0), 0);
6060
int kx = 0;

backends/vulkan/runtime/graph/ops/glsl/conv2d_dw_output_tile.glsl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ void main() {
9797
for (int y = start.y, i = 0; i < TILE_SIZE + BATCH_SIZE_Y - 1; y += dilation.y, i++) {
9898
for (int x = start.x, j = 0; j < TILE_SIZE + BATCH_SIZE_X - 1; x += dilation.x, j++) {
9999
in_texels[j] = texelFetch(t_in, ivec3(x, y, pos.z), 0);
100+
// Set to zero if reading out of bounds
101+
if (any(greaterThanEqual(ivec2(x, y), in_sizes.xy))) {
102+
in_texels[j] = VEC4_T(0);
103+
}
100104
}
101105

102106
// from 2nd iteration onwards accumulate dot product in 2nd sum

0 commit comments

Comments
 (0)