Skip to content

[ET-VK][EZ] Assign trivially moveable values to const-ref variables #2834

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 2 commits 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
4 changes: 2 additions & 2 deletions backends/vulkan/runtime/graph/ops/PrepackNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ void PrepackNode::encode(ComputeGraph* graph) {
api::Context* const context = graph->context();
api::PipelineBarrier pipeline_barrier{};

TensorRef tref = graph->get_val(tref_).toTensorRef();
vTensor packed = graph->get_val(packed_).toTensor();
TensorRef& tref = graph->get_val(tref_).toTensorRef();
vTensor& packed = graph->get_val(packed_).toTensor();

size_t numel = api::utils::multiply_integers(tref.sizes);
api::StorageBuffer staging(graph->context(), tref.dtype, numel);
Expand Down
2 changes: 1 addition & 1 deletion backends/vulkan/runtime/graph/ops/impl/Staging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ ValueRef prepack(
const api::GPUMemoryLayout layout) {
TensorRef& tref = graph.get_val(vref).toTensorRef();
ValueRef v = graph.add_tensor(tref.sizes, tref.dtype, layout);
vTensor t = graph.get_val(v).toTensor();
vTensor& t = graph.get_val(v).toTensor();

api::ShaderInfo shader = get_nchw_to_image_shader(t);

Expand Down
2 changes: 1 addition & 1 deletion backends/vulkan/runtime/graph/ops/impl/Sum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void add_sum_dim_IntList(
vTensor& in_tensor = graph.get_val(in).toTensor();

std::set<int64_t> dims_set;
auto dims_to_sum = graph.get_val(opt_dim).toIntList();
const auto& dims_to_sum = graph.get_val(opt_dim).toIntList();
int64_t in_dim = in_tensor.sizes().size();

for (const auto& dim : dims_to_sum) {
Expand Down
4 changes: 2 additions & 2 deletions backends/vulkan/test/vulkan_compute_api_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ TEST(VulkanComputeGraphTest, test_values_scalar_list_inplace_constructed) {
ComputeGraph graph(config);

ValueRef idx = graph.add_scalar_list<int64_t>({1, 2, 3, 4});
std::vector<int64_t>& arr = graph.get_val(idx).toIntList();
const auto& arr = graph.get_val(idx).toIntList();
EXPECT_TRUE(arr.size() == 4);
for (int i = 0; i < 4; i++) {
EXPECT_TRUE(arr[i] == i + 1);
Expand All @@ -417,7 +417,7 @@ TEST(VulkanComputeGraphTest, test_values_scalar_list_outside_constructed) {
std::vector<double> data = {5.0, 4.0, 3.0, 2.0, 1.0};
idx = graph.add_scalar_list(std::move(data));
}
std::vector<double>& arr = graph.get_val(idx).toDoubleList();
const auto& arr = graph.get_val(idx).toDoubleList();
EXPECT_TRUE(arr.size() == 5);
for (int i = 0; i < 5; i++) {
EXPECT_TRUE(arr[i] == (5 - i));
Expand Down