Characterization of traces of smooth functions on Ahlfors regular sets