@@ -117,8 +117,7 @@ struct Value final {
117117 CASE_MOVE_TRIVIALLY_COPYABLE_TYPE (TypeTag::INT, as_int);
118118 CASE_MOVE_TRIVIALLY_COPYABLE_TYPE (TypeTag::DOUBLE, as_double);
119119 CASE_MOVE_TRIVIALLY_COPYABLE_TYPE (TypeTag::BOOL, as_bool);
120- // Tensor and tensor adjacent types
121- CASE_MOVE_UNIQUE_PTR_TYPE (TypeTag::TENSOR, as_tensor);
120+ // Tensor adjacent types
122121 CASE_MOVE_MOVEABLE_TYPE (
123122 TypeTag::STAGING, api::StagingBuffer, as_staging, StagingBuffer);
124123 CASE_MOVE_MOVEABLE_TYPE (
@@ -136,6 +135,8 @@ struct Value final {
136135 CASE_MOVE_MOVEABLE_TYPE (
137136 TypeTag::STRING, std::string, as_string, basic_string);
138137 CASE_MOVE_MOVEABLE_TYPE (TypeTag::SYMINT, SymInt, as_symint, SymInt);
138+ // Tensor type
139+ CASE_MOVE_UNIQUE_PTR_TYPE (TypeTag::TENSOR, as_tensor);
139140
140141 case TypeTag::NONE:
141142 clearToNone ();
@@ -162,9 +163,6 @@ struct Value final {
162163
163164 ~Value () {
164165 switch (tag) {
165- case TypeTag::TENSOR:
166- payload.as_tensor .reset ();
167- break ;
168166 case TypeTag::STAGING:
169167 payload.as_staging .~StagingBuffer ();
170168 break ;
@@ -196,6 +194,9 @@ struct Value final {
196194 case TypeTag::DOUBLE:
197195 case TypeTag::BOOL:
198196 break ;
197+ case TypeTag::TENSOR:
198+ payload.as_tensor .reset ();
199+ break ;
199200 }
200201 }
201202
@@ -232,39 +233,6 @@ struct Value final {
232233
233234#undef SUPPORT_TRIVIALLY_COPYABLE_TYPE
234235
235- #define SUPPORT_TRIVIALLY_MOVEABLE_UNIQUE_PTR_TYPE ( \
236- type, type_name, type_tag, member_name) \
237- explicit Value (type t) : tag(type_tag) { \
238- payload.member_name = std::make_unique<type>(std::move (t)); \
239- } \
240- inline bool is##type_name() const { \
241- return tag == type_tag; \
242- } \
243- inline type& to##type_name() const { \
244- VK_CHECK_COND ( \
245- is##type_name (), \
246- " Expected value to have type " #type_name " , got " , \
247- tag, \
248- " instead." ); \
249- return *payload.member_name ; \
250- } \
251- inline const type& toConst##type_name() const { \
252- VK_CHECK_COND ( \
253- is##type_name (), \
254- " Expected value to have type " #type_name " , got " , \
255- tag, \
256- " instead." ); \
257- return *payload.member_name ; \
258- }
259-
260- SUPPORT_TRIVIALLY_MOVEABLE_UNIQUE_PTR_TYPE (
261- api::vTensor,
262- Tensor,
263- TypeTag::TENSOR,
264- as_tensor);
265-
266- #undef SUPPORT_TRIVIALLY_MOVEABLE_UNIQUE_PTR_TYPE
267-
268236#define SUPPORT_TRIVIALLY_MOVEABLE_TYPE ( \
269237 type, type_name, type_tag, member_name) \
270238 explicit Value (type&& t) : tag(type_tag) { \
@@ -334,9 +302,36 @@ struct Value final {
334302
335303 SUPPORT_TRIVIALLY_MOVEABLE_TYPE (SymInt, SymInt, TypeTag::SYMINT, as_symint);
336304
337- #undef SUPPORT_TRIVIALLY_COPYABLE_TYPE
338305#undef SUPPORT_TRIVIALLY_MOVEABLE_TYPE
339306
307+ #define SUPPORT_UNIQUE_PTR_TYPE (type, type_name, type_tag, member_name ) \
308+ explicit Value (type t) : tag(type_tag) { \
309+ payload.member_name = std::make_unique<type>(std::move (t)); \
310+ } \
311+ inline bool is##type_name() const { \
312+ return tag == type_tag; \
313+ } \
314+ inline type& to##type_name() const { \
315+ VK_CHECK_COND ( \
316+ is##type_name (), \
317+ " Expected value to have type " #type_name " , got " , \
318+ tag, \
319+ " instead." ); \
320+ return *payload.member_name ; \
321+ } \
322+ inline const type& toConst##type_name() const { \
323+ VK_CHECK_COND ( \
324+ is##type_name (), \
325+ " Expected value to have type " #type_name " , got " , \
326+ tag, \
327+ " instead." ); \
328+ return *payload.member_name ; \
329+ }
330+
331+ SUPPORT_UNIQUE_PTR_TYPE (api::vTensor, Tensor, TypeTag::TENSOR, as_tensor);
332+
333+ #undef SUPPORT_UNIQUE_PTR_TYPE
334+
340335 private:
341336 Payload payload;
342337 TypeTag tag;
0 commit comments