Skip to content
Open
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
9 changes: 7 additions & 2 deletions backends/vulkan/op_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,11 @@ def register_torchao_quantize_dequantize():
)


# =============================================================================
# Q8taQuantizeDequantize.cpp
# =============================================================================


@update_features(
[
exir_ops.edge.quantized_decomposed.quantize_per_tensor.default,
Expand All @@ -443,7 +448,7 @@ def register_quantize_per_tensor():
utils.CHANNELS_PACKED_TEXTURE_OR_CONTIGUOUS_BUFFER,
],
outputs_storage=[
utils.PACKED_INT8_4W4C_BUFFER,
utils.PACKED_INT8_BUFFER,
],
)

Expand All @@ -457,7 +462,7 @@ def register_quantize_per_tensor():
def register_dequantize_per_tensor():
return OpFeatures(
inputs_storage=[
utils.PACKED_INT8_4W4C_BUFFER,
utils.PACKED_INT8_BUFFER,
],
outputs_storage=[
utils.CHANNELS_PACKED_TEXTURE_OR_CONTIGUOUS_BUFFER,
Expand Down
2 changes: 2 additions & 0 deletions backends/vulkan/runtime/VulkanBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ utils::GPUMemoryLayout get_memory_layout(
return utils::kPackedInt8_4W4C;
case vkgraph::VkMemoryLayout::PACKED_INT8_4H4W:
return utils::kPackedInt8_4H4W;
case vkgraph::VkMemoryLayout::PACKED_INT8_4C1W:
return utils::kPackedInt8_4C1W;
default:
break;
}
Expand Down
1 change: 1 addition & 0 deletions backends/vulkan/serialization/schema.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ enum VkMemoryLayout : ubyte {
TENSOR_CHANNELS_PACKED = 2,
PACKED_INT8_4W4C = 3,
PACKED_INT8_4H4W = 4,
PACKED_INT8_4C1W = 8,
DEFAULT_LAYOUT = 255,
}

Expand Down
1 change: 1 addition & 0 deletions backends/vulkan/serialization/vulkan_graph_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class VkMemoryLayout(IntEnum):
TENSOR_CHANNELS_PACKED = 2
PACKED_INT8_4W4C = 3
PACKED_INT8_4H4W = 4
PACKED_INT8_4C1W = 8
DEFAULT_LAYOUT = 255

def __str__(self) -> str:
Expand Down
8 changes: 8 additions & 0 deletions backends/vulkan/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ def node_has_target(node: Any, target: str):
all_quantized_memory_layouts: Set[VkMemoryLayout] = {
VkMemoryLayout.PACKED_INT8_4W4C,
VkMemoryLayout.PACKED_INT8_4H4W,
VkMemoryLayout.PACKED_INT8_4C1W,
}

universal_memory_layout_set: Set[VkMemoryLayout] = {
Expand Down Expand Up @@ -983,7 +984,14 @@ def make_filtered_tensor_repset(

# Only includes memory layouts that can be used by quantized tensors

PACKED_INT8_BUFFER = TensorRepSet(all_quantized_memory_layouts, set())
PACKED_INT8_4W4C_BUFFER = TensorRepSet({VkMemoryLayout.PACKED_INT8_4W4C}, set())
PACKED_INT8_4C1W_BUFFER = TensorRepSet({VkMemoryLayout.PACKED_INT8_4C1W}, set())

PACKED_INT8_CHANNELS_PACKED_BUFFER = TensorRepSet(
{VkMemoryLayout.PACKED_INT8_4W4C, VkMemoryLayout.PACKED_INT8_4C1W}, set()
)


# Special use RepSets

Expand Down
Loading