@@ -55,6 +55,10 @@ def __init__(
5555 self .valid_packed_dims = valid_packed_dims
5656
5757 def valid_memory_layouts (self ) -> Set [VkMemoryLayout ]:
58+ """
59+ Derive the set of memory layouts supported by the texture implementation based
60+ on the valid packed dimensions.
61+ """
5862 layouts = set ()
5963
6064 if PackedDim .WIDTH in self .valid_packed_dims :
@@ -112,6 +116,15 @@ def __init__(
112116 self .check_node_fn = check_node_fn
113117
114118 def propose_storage_type (self ) -> Optional [VkStorageType ]:
119+ """
120+ Propose a storage type that should be used for this operator. A proposal can be
121+ made if one of the following is true:
122+ 1. The operator specifies an optimal storage type
123+ 2. Only one storage type is supported.
124+
125+ If both storage types are supported and no optimal storage type is specified,
126+ then None is returned to indicate that there is no preference in storage type.
127+ """
115128 if self .optimal_storage is not None :
116129 return self .optimal_storage
117130
@@ -123,6 +136,9 @@ def propose_storage_type(self) -> Optional[VkStorageType]:
123136 return None
124137
125138 def supported_storage_types (self ) -> Set [VkStorageType ]:
139+ """
140+ Return the set of storage types supported by this operator.
141+ """
126142 storage_types = set ()
127143 if self .texture_impl is not None :
128144 storage_types .add (VkStorageType .TEXTURE_3D )
@@ -132,6 +148,16 @@ def supported_storage_types(self) -> Set[VkStorageType]:
132148 return storage_types
133149
134150 def propose_memory_layout (self , storage : VkStorageType ) -> Optional [VkMemoryLayout ]:
151+ """
152+ Given a storage type as a precondition, propose a memory layout that should be
153+ used for this operator. A proposal can be made if one of the following is true:
154+ 1. The operator specifies an optimal memory layout
155+ 2. Only one memory layout is supported.
156+
157+ If multiple memory layouts are supported and no optimal memory layout is
158+ specified then return None to indicate that the "best" memory layout for the
159+ operator is ambiguous.
160+ """
135161 if self .optimal_layout is not None :
136162 return self .optimal_layout
137163
@@ -144,6 +170,10 @@ def propose_memory_layout(self, storage: VkStorageType) -> Optional[VkMemoryLayo
144170 return None
145171
146172 def supported_memory_layouts (self , storage : VkStorageType ) -> Set [VkMemoryLayout ]:
173+ """
174+ Return the set of memory layouts supported by this operator for a given storage
175+ type.
176+ """
147177 if storage == VkStorageType .TEXTURE_3D :
148178 assert self .texture_impl is not None
149179 return self .texture_impl .valid_memory_layouts ()
@@ -517,13 +547,5 @@ def get_op_features(target: OpKey) -> OpFeatures:
517547 return vulkan_supported_ops [target ]
518548
519549
520- def optimal_storage_type (target : OpKey ) -> Optional [VkStorageType ]:
521- return get_op_features (target ).optimal_storage
522-
523-
524- def optimal_memory_layout (target : OpKey ) -> Optional [VkMemoryLayout ]:
525- return get_op_features (target ).optimal_layout
526-
527-
528550def handles_own_prepacking (target : OpKey ) -> bool :
529551 return get_op_features (target ).handles_own_prepacking
0 commit comments