cherry-picked 'possible fix for sparse matrix conversion'