Use template specilization to fix template version dynamic shared memory