Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 14 additions & 5 deletions backends/vulkan/runtime/graph/ComputeGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ ValueRef ComputeGraph::add_tensor(
return idx;
}

ValueRef ComputeGraph::add_tensor(
TensorRef& tref,
const api::StorageType storage_type,
const api::GPUMemoryLayout memory_layout) {
return add_tensor(tref.sizes, tref.dtype, storage_type, memory_layout);
}

ValueRef ComputeGraph::add_tensor(
const std::vector<int64_t>& sizes,
const api::ScalarType dtype,
Expand All @@ -132,16 +139,18 @@ ValueRef ComputeGraph::add_tensor(
sizes, dtype, suggested_storage_type(), memory_layout, shared_object_idx);
}

ValueRef ComputeGraph::add_tensor(
TensorRef& tref,
const api::GPUMemoryLayout memory_layout) {
return add_tensor(tref.sizes, tref.dtype, memory_layout);
}

ValueRef ComputeGraph::add_tensor(
const std::vector<int64_t>& sizes,
const api::ScalarType dtype,
const int64_t shared_object_idx) {
return add_tensor(
sizes,
dtype,
suggested_storage_type(),
suggested_memory_layout(sizes),
shared_object_idx);
sizes, dtype, suggested_memory_layout(sizes), shared_object_idx);
}

ValueRef ComputeGraph::add_tensorref(
Expand Down
20 changes: 18 additions & 2 deletions backends/vulkan/runtime/graph/ComputeGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,15 @@ class ComputeGraph final {
const api::ScalarType dtype,
const api::StorageType storage_type,
const api::GPUMemoryLayout memory_layout,
const int64_t shared_object_idx);
const int64_t shared_object_idx = -1);

/*
* Add a `vTensor` value to the graph with the properties of `tref`.
*/
ValueRef add_tensor(
TensorRef& tref,
const api::StorageType storage_type,
const api::GPUMemoryLayout memory_layout);

/*
* Add a `vTensor` value to the graph with the specified properties. The
Expand All @@ -184,14 +192,22 @@ class ComputeGraph final {
const api::GPUMemoryLayout memory_layout,
const int64_t shared_object_idx = -1);

/*
* Add a `vTensor` value to the graph with the properties of `tref`. The
* suggested storage type will be used to construct the `vTensor`.
*/
ValueRef add_tensor(
TensorRef& tref,
const api::GPUMemoryLayout memory_layout);

/*
* Add a `vTensor` value to the graph with the specified properties. The
* suggested storage type and memory layout will be used to construct the
* `vTensor`.
*/
ValueRef add_tensor(
const std::vector<int64_t>& sizes,
const api::ScalarType dtype = api::ScalarType::Float,
const api::ScalarType dtype,
const int64_t shared_object_idx = -1);

/*
Expand Down
3 changes: 1 addition & 2 deletions backends/vulkan/runtime/graph/ops/impl/Staging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ ValueRef prepack(
ComputeGraph& graph,
const ValueRef vref,
const api::GPUMemoryLayout layout) {
TensorRef& tref = graph.get_val(vref).toTensorRef();
ValueRef v = graph.add_tensor(tref.sizes, tref.dtype, layout);
ValueRef v = graph.add_tensor(graph.get_val(vref).toTensorRef(), layout);
vTensor& t = graph.get_val(v).toTensor();

api::ShaderInfo shader = get_nchw_to_image_shader(t);
Expand Down