fix linear indexing in hardtanh