Skip to content

[ET-VK] Call destructor explicitly when move constructing Value #3148

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
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
22 changes: 13 additions & 9 deletions backends/vulkan/runtime/graph/containers/Value.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ struct Value final {
payload.u.member_name = rhs.payload.u.member_name; \
break;

#define CASE_MOVE_MOVEABLE_TYPE(type_tag, type, member_name) \
#define CASE_MOVE_MOVEABLE_TYPE(type_tag, type, member_name, dtor_name) \
case type_tag: \
new (&payload.member_name) type(std::move(rhs.payload.member_name)); \
rhs.payload.member_name.~dtor_name(); \
break;

Value(Value&& rhs) noexcept : tag(rhs.tag) {
Expand All @@ -105,20 +106,23 @@ struct Value final {
CASE_MOVE_TRIVIALLY_COPYABLE_TYPE(TypeTag::DOUBLE, as_double);
CASE_MOVE_TRIVIALLY_COPYABLE_TYPE(TypeTag::BOOL, as_bool);
// Tensor and tensor adjacent types
CASE_MOVE_MOVEABLE_TYPE(TypeTag::TENSOR, vTensor, as_tensor);
CASE_MOVE_MOVEABLE_TYPE(TypeTag::STAGING, api::StorageBuffer, as_staging);
CASE_MOVE_MOVEABLE_TYPE(TypeTag::TENSORREF, TensorRef, as_tensorref);
CASE_MOVE_MOVEABLE_TYPE(TypeTag::TENSOR, vTensor, as_tensor, vTensor);
CASE_MOVE_MOVEABLE_TYPE(
TypeTag::STAGING, api::StorageBuffer, as_staging, StorageBuffer);
CASE_MOVE_MOVEABLE_TYPE(
TypeTag::TENSORREF, TensorRef, as_tensorref, TensorRef);
// Scalar lists
CASE_MOVE_MOVEABLE_TYPE(
TypeTag::INTLIST, std::vector<int64_t>, as_int_list);
TypeTag::INTLIST, std::vector<int64_t>, as_int_list, vector);
CASE_MOVE_MOVEABLE_TYPE(
TypeTag::DOUBLELIST, std::vector<double>, as_double_list);
TypeTag::DOUBLELIST, std::vector<double>, as_double_list, vector);
CASE_MOVE_MOVEABLE_TYPE(
TypeTag::BOOLLIST, std::vector<bool>, as_bool_list);
TypeTag::BOOLLIST, std::vector<bool>, as_bool_list, vector);
// Special types
CASE_MOVE_MOVEABLE_TYPE(
TypeTag::VALUELIST, std::vector<ValueRef>, as_value_list);
CASE_MOVE_MOVEABLE_TYPE(TypeTag::STRING, std::string, as_string);
TypeTag::VALUELIST, std::vector<ValueRef>, as_value_list, vector);
CASE_MOVE_MOVEABLE_TYPE(
TypeTag::STRING, std::string, as_string, basic_string);

case TypeTag::NONE:
clearToNone();
Expand Down