DS-Net++: Dynamic Weight Slicing for Efficient Inference in CNNs and Vision Transformers