Hi Hao,
I didn’t get what you mean “prune the same layer using PolynomialDecay and ConstantSparsity”. They are both exclusive, so you can choose only one pruning schedule between the two. Please explain how you want to prune your model, then we can help you.
The error is raised since you tried to Prune a layer which is already pruned. And you are right, the if statement let us bypassing the all pruned layers so the error was gone.