I don’t think the code you’ve posted achieves your desired results.
Based on the description from the TF weight clustering approach it seems as if parameters are reused (i.e. views are actually used) in the new layers, so that the original memory footprint would be reduced.
In your current code snippet you would replace some values of the parameters, but all values would still be stored independently, wouldn’t they?