Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion backends/vulkan/runtime/graph/ops/glsl/conv2d.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,17 @@ void main() {

// Compute the start and end of the input indices to load. Padding is assumed
// to be constant 0 padding, so reads from the padding region are skipped.
const ivec2 start = max(ivec2(0), ipos);
ivec2 start = ipos;
if (start.x < 0) {
// number of "steps" to get to >= zero is div_up(-start, dilation)
int num_steps = ((-ipos.x) + dilation.x - 1) / dilation.x;
start.x = ipos.x + num_steps * dilation.x;
}
if (start.y < 0) {
// number of "steps" to get to >= zero is div_up(-start, dilation)
int num_steps = ((-ipos.y) + dilation.y - 1) / dilation.y;
start.y = ipos.y + num_steps * dilation.y;
}
const ivec2 end = min(ipos + overlay_region.xy, ivec2(in_sizes.xy));
// Compute the start of the kernel based on how far we are skipping ahead when
// reading the input. Note that these are "canonical" indices.
Expand Down
5 changes: 0 additions & 5 deletions backends/vulkan/runtime/graph/ops/impl/Convolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,6 @@ void check_conv2d_params(const Kernel2dParams& p, const bool transposed) {
"aten.convolution.default: transposed = true, dilation > 1 is not supported yet!");
}
}
if ((p.padding[0] > 0 && p.kernel_size[0] > 1 && p.dilation[0] > 1) ||
(p.padding[1] > 0 && p.kernel_size[1] > 1 && p.dilation[1] > 1)) {
VK_THROW(
"aten.convolution.default: padding > 0 while dilation, kernel_size > 1 is not supported yet!");
}
}

Conv2dMethod get_conv2d_method(
Expand Down
327 changes: 182 additions & 145 deletions backends/vulkan/test/op_tests/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,153 +226,190 @@ def get_max_pool2d_inputs():

@register_test_suite("aten.convolution.default")
def get_conv_inputs():
test_suite = VkTestSuite(
Test = namedtuple(
"ConvTest",
[
(
(1, 6, 40, 50),
(8, 6, 3, 3),
(8,),
[1, 2],
[2, 3],
[1, 1],
False,
[0, 0],
1,
),
(
(1, 6, 40, 50),
(6, 8, 3, 3),
(8,),
[1, 2],
[2, 3],
[1, 1],
True,
[0, 1],
1,
),
(
(1, 8, 72, 96),
(8, 1, 3, 3),
(8,),
[1, 1],
[1, 1],
[1, 1],
False,
[0, 0],
8,
),
(
(1, 8, 72, 96),
(8, 8, 1, 1),
(8,),
[1, 1],
[1, 1],
[1, 1],
False,
[0, 0],
1,
),
(
(1, 6, 40, 50),
(8, 6, 3, 3),
None,
[1, 2],
[2, 3],
[1, 1],
False,
[0, 0],
1,
),
(
(1, 6, 7),
(6, 1, 3),
(6,),
[1],
[0],
[1],
False,
[0],
6,
),
(
(2, 20, 30),
(10, 4, 6),
(10,),
[5],
[5],
[3],
False,
[0],
5,
),
(
(1, 9, 11),
(9, 1, 3),
None,
[1],
[0],
[1],
False,
[0],
9,
),
(
(5, 15, 30),
(20, 3, 3),
None,
[3],
[5],
[7],
False,
[0],
5,
),
(
(1, 16, 672, 512),
(64, 16, 1, 1),
(64,),
[1, 1],
[0, 0],
[1, 1],
False,
[0, 0],
1,
),
(
(1, 4, 234, 234),
(4, 1, 3, 3),
(4,),
[2, 1],
[1, 1],
[1, 1],
False,
[0, 0],
4,
),
(
(1, 4, 234, 234),
(4, 1, 3, 3),
(4,),
[1, 2],
[1, 1],
[1, 1],
False,
[0, 0],
4,
),
(
(1, 4, 234, 234),
(4, 1, 3, 3),
(4,),
[2, 2],
[1, 1],
[1, 1],
False,
[0, 0],
4,
),
]
"self",
"weight",
"bias",
"stride",
"padding",
"dilation",
"transposed",
"output_padding",
"groups",
],
)
Test.__new__.__defaults__ = (
None,
None,
None,
[1, 1],
[0, 0],
[1, 1],
False,
[9, 0],
1,
)
test_cases = []
test_cases = [
Test(
self=(1, 6, 40, 50),
weight=(8, 6, 3, 3),
bias=(8,),
stride=[1, 2],
padding=[2, 3],
dilation=[1, 1],
transposed=False,
output_padding=[0, 0],
groups=1,
),
Test(
self=(1, 6, 40, 50),
weight=(6, 8, 3, 3),
bias=(8,),
stride=[1, 2],
padding=[2, 3],
dilation=[1, 1],
transposed=True,
output_padding=[0, 1],
groups=1,
),
Test(
self=(1, 8, 72, 96),
weight=(8, 1, 3, 3),
bias=(8,),
stride=[1, 1],
padding=[1, 1],
dilation=[1, 1],
transposed=False,
output_padding=[0, 0],
groups=8,
),
Test(
self=(1, 8, 72, 96),
weight=(8, 8, 1, 1),
bias=(8,),
stride=[1, 1],
padding=[1, 1],
dilation=[1, 1],
transposed=False,
output_padding=[0, 0],
groups=1,
),
Test(
self=(1, 6, 40, 50),
weight=(8, 6, 3, 3),
bias=None,
stride=[1, 2],
padding=[2, 3],
dilation=[1, 1],
transposed=False,
output_padding=[0, 0],
groups=1,
),
Test(
self=(1, 6, 7),
weight=(6, 1, 3),
bias=(6,),
stride=[1],
padding=[0],
dilation=[1],
transposed=False,
output_padding=[0],
groups=6,
),
Test(
self=(2, 20, 30),
weight=(10, 4, 6),
bias=(10,),
stride=[5],
padding=[5],
dilation=[3],
transposed=False,
output_padding=[0],
groups=5,
),
Test(
self=(1, 9, 11),
weight=(9, 1, 3),
bias=None,
stride=[1],
padding=[0],
dilation=[1],
transposed=False,
output_padding=[0],
groups=9,
),
Test(
self=(5, 15, 30),
weight=(20, 3, 3),
bias=None,
stride=[3],
padding=[5],
dilation=[7],
transposed=False,
output_padding=[0],
groups=5,
),
Test(
self=(1, 16, 672, 512),
weight=(64, 16, 1, 1),
bias=(64,),
stride=[1, 1],
padding=[0, 0],
dilation=[1, 1],
transposed=False,
output_padding=[0, 0],
groups=1,
),
Test(
self=(1, 4, 234, 234),
weight=(4, 1, 3, 3),
bias=(4,),
stride=[2, 1],
padding=[1, 1],
dilation=[1, 1],
transposed=False,
output_padding=[0, 0],
groups=4,
),
Test(
self=(1, 4, 234, 234),
weight=(4, 1, 3, 3),
bias=(4,),
stride=[1, 2],
padding=[1, 1],
dilation=[1, 1],
transposed=False,
output_padding=[0, 0],
groups=4,
),
Test(
self=(1, 4, 234, 234),
weight=(4, 1, 3, 3),
bias=(4,),
stride=[2, 2],
padding=[1, 1],
dilation=[1, 1],
transposed=False,
output_padding=[0, 0],
groups=4,
),
Test(
self=(1, 8, 90, 77),
weight=(1, 8, 3, 3),
bias=(1,),
stride=[1, 1],
padding=[2, 2],
dilation=[2, 2],
transposed=False,
output_padding=[0, 0],
groups=1,
),
]

test_suite = VkTestSuite(test_cases)
return test_suite


Expand Down
Loading