Skip to content

Add resize function for aten.upsample_nearest2d.vec operator #4069

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
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
27 changes: 26 additions & 1 deletion backends/vulkan/runtime/graph/ops/impl/Upsample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,29 @@

namespace vkcompute {

void resize_upsample_nearest2d_node(
ComputeGraph* graph,
const std::vector<ArgGroup>& args,
const std::vector<ValueRef>& extra_args) {
vTensorPtr out = graph->get_tensor(args[0].refs[0]);
vTensorPtr self = graph->get_tensor(args[1].refs[0]);
std::vector<int64_t> out_sizes = self->sizes(); // NCHW

const ValueRef output_sizes = extra_args[0]; // HW
const ValueRef scale_factors = extra_args[1]; // HW
if (!graph->val_is_none(output_sizes)) {
IntListPtr output_size_ref = graph->get_int_list(output_sizes);
out_sizes.at(2) = output_size_ref->at(0);
out_sizes.at(3) = output_size_ref->at(1);
} else {
DoubleListPtr scales = graph->get_double_list(scale_factors);
out_sizes.at(2) *= scales->at(0);
out_sizes.at(3) *= scales->at(1);
}

out->virtual_resize(out_sizes);
}

// ExecuTorch-Vulkan framework to add node
// Args:
// in: will be converted from NCHW input tensor to 3D ARGB representation in
Expand Down Expand Up @@ -87,7 +110,9 @@ void add_upsample_nearest2d_node(
graph.create_params_buffer(input_size),
graph.create_params_buffer(rev_scales)},
// Specialization Constants
{}));
{},
resize_upsample_nearest2d_node,
{output_sizes, scale_factors}));
}

void upsample(ComputeGraph& graph, const std::vector<ValueRef>& args) {
Expand Down
Loading