last)
pipe.vae.to(memory_format=torch.channels_last) Since dynamic quantization is only limited to the linear layers, convert the appropriate pointwise convolution layers into linear layers to maximize its benefit.   Copied from torchao import swap_conv2d_1x1_to_linear

swap_conv2d_1x1_to_linear(pipe.unet, conv_filter_fn)
swap_conv2d_1x1_to_linear(pipe.vae, conv_filter_fn) Apply dynamic quantization:   Copied from torchao import apply_dynamic_q