From ce6739f57a1a621f356b019894dd174a49d80abc Mon Sep 17 00:00:00 2001 From: Akhmed Rakhmati Date: Wed, 3 Jan 2024 16:18:58 +0000 Subject: [PATCH] #4514: fixed the bug in ttnn.reshape --- ttnn/core.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/ttnn/core.py b/ttnn/core.py index 1dc6e305866..0ff07baef61 100644 --- a/ttnn/core.py +++ b/ttnn/core.py @@ -1110,18 +1110,15 @@ def ttnn_reshape(tensor, shape): ttnn_reshape = ttl.tensor.decorate_external_operation(ttnn_reshape, function_name="ttnn.reshape") - if input_tensor.is_contiguous(): - if has_storage_type_of(input_tensor, ttl.tensor.StorageType.DEVICE): - # Page size depends on the width, so only modify the shape if the width is the same - if input_tensor.shape[-1] == shape[-1]: - return ttnn_reshape(input_tensor, shape) - else: + # Page size depends on the width, so only modify the shape if the width is the same + if input_tensor.shape[-1] == shape[-1]: + if input_tensor.is_contiguous(): return ttnn_reshape(input_tensor, shape) - if input_tensor.layout == TILE_LAYOUT: - *_, new_height, new_width = tuple(shape.padded()) - if new_height % TILE_SIZE == 0 and new_width % TILE_SIZE == 0: - return ttnn_reshape(input_tensor, shape) + if input_tensor.layout == TILE_LAYOUT: + *_, new_height, new_width = tuple(shape.padded()) + if new_height % TILE_SIZE == 0 and new_width % TILE_SIZE == 0: + return ttnn_reshape(input_tensor, shape) if ( has_storage_type_of(input_tensor, ttl.tensor.StorageType.DEVICE)