Skip to content
Closed
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
5 changes: 5 additions & 0 deletions backends/xnnpack/operators/node_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ def define_tensor(
# Get new xnn id for tensor value
ext_id, id_out, flag = self.gen_ids_and_flags(tensor, xnn_graph, quant_params)
dims = get_shape(tensor)
dims = [1] if len(dims) == 0 else dims

# constant values serialize data
buffer_idx = self.get_serialized_buffer(
Expand Down Expand Up @@ -336,6 +337,10 @@ def get_serialized_buffer(
# Quantize buffer if static data is indeed quantized
if quant_params is not None and not quant_params.is_dynamic:
const_val = quant_params.quantize_tensor(const_val).contiguous()
else:
# ensure that the const is fp32
const_val = const_val.to(dtype=torch.float32).contiguous()

if swap_nc_for_depthwise_weights:
const_val = const_val.permute(
dims=((1, 0) + tuple(range(2, const_val.dim())))
Expand Down
3 changes: 3 additions & 0 deletions backends/xnnpack/partition/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@

SUPPORTED_MODULES = [
torch.nn.Conv1d,
# TODO(T161981984) recomposed hardswish into a single node
torch.nn.Hardswish,
torch.nn.Hardsigmoid,
torch.nn.Conv2d,
torch.nn.ReLU,
torch.nn.Sigmoid,
Expand Down