Skip to content

aten.minimum.default #4192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions backends/vulkan/partitioner/supported_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __contains__(self, op):
BINARY_OPS = [
exir_ops.edge.aten.add.Tensor,
exir_ops.edge.aten.sub.Tensor,
exir_ops.edge.aten.minimum.default,
exir_ops.edge.aten.mul.Tensor,
exir_ops.edge.aten.div.Tensor,
exir_ops.edge.aten.div.Tensor_mode,
Expand Down
2 changes: 2 additions & 0 deletions backends/vulkan/runtime/graph/ops/glsl/binary_op.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ binary_op:
OPERATOR: pow(X, Y)
- NAME: binary_floor_divide
OPERATOR: floor(X / Y)
- NAME: binary_minimum
OPERATOR: min(X, Y)
2 changes: 2 additions & 0 deletions backends/vulkan/runtime/graph/ops/impl/BinaryOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ DEFINE_BINARY_OP_WITH_ALPHA_FN(floor_divide);
DEFINE_BINARY_OP_FN(mul);
DEFINE_BINARY_OP_FN(div);
DEFINE_BINARY_OP_FN(pow);
DEFINE_BINARY_OP_FN(minimum);

REGISTER_OPERATORS {
VK_REGISTER_OP(aten.add.Tensor, add);
Expand All @@ -126,6 +127,7 @@ REGISTER_OPERATORS {
VK_REGISTER_OP(aten.div.Tensor, div);
VK_REGISTER_OP(aten.div.Tensor_mode, floor_divide);
VK_REGISTER_OP(aten.pow.Tensor_Tensor, pow);
VK_REGISTER_OP(aten.minimum.default, minimum);
}

} // namespace vkcompute
16 changes: 16 additions & 0 deletions backends/vulkan/test/op_tests/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,3 +1022,19 @@ def get_constant_pad_nd_inputs():
]
)
return test_suite


@register_test_suite("aten.minimum.default")
def get_minimum_inputs():
test_suite = VkTestSuite(
[
((M1, M2), (M2)),
((M1, M2), (M1, M2)),
((M1, M2, M), (M2, M)),
((M1, M1, S1, S2), (M1, M1, S1, S2)),
((S1, S1, S2, S), (S1, S2, S)),
((M1, S1, S2), (L, M1, S1, S2)),
((S1, S2), (L, M1, S1, S2)),
]
)
return test_suite
19 changes: 19 additions & 0 deletions backends/vulkan/test/test_vulkan_delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,25 @@ def forward(self, x):
memory_layouts=[vk_graph_schema.VkMemoryLayout.TENSOR_CHANNELS_PACKED],
)

def test_vulkan_backend_minimum(self):
class MinimumModule(torch.nn.Module):
def __init__(self):
super().__init__()

def forward(self, x, y):
return torch.minimum(x, y)

sample_inputs = (
torch.rand(size=(3, 5, 6, 4), dtype=torch.float32),
torch.rand(size=(6, 4), dtype=torch.float32),
)

self.lower_module_and_test_output(
MinimumModule(),
sample_inputs,
memory_layouts=[vk_graph_schema.VkMemoryLayout.TENSOR_CHANNELS_PACKED],
)

def test_vulkan_backend_reshape(self):
class ReshapeModule(torch.nn.Module):
def __init__(self):
Expand Down
Loading