datatensor casting caches memory