-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#8653: Parametrize option to select device tilizer in ttnn.as_tensor(…
…..) api - Selectively use multi-core device tilizer to work around #8617
- Loading branch information
Showing
3 changed files
with
66 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc. | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import torch | ||
import ttnn | ||
from loguru import logger | ||
|
||
|
||
def test_device_tilize(device): | ||
"""Benchmark host vs. device tilizer for converting torch tensor to tilized tensor.""" | ||
import time | ||
|
||
torch_tensor = torch.randn((4544, 18176), dtype=torch.bfloat16) | ||
output_dtype = ttnn.bfloat8_b | ||
|
||
start = time.time() | ||
tensor = ttnn.from_torch(torch_tensor, dtype=output_dtype, layout=ttnn.TILE_LAYOUT) | ||
end = time.time() | ||
logger.info(f"Time taken to convert to tensor using host-tilizer: {end-start}") | ||
|
||
start = time.time() | ||
tensor = ttnn.from_torch( | ||
torch_tensor, layout=ttnn.ROW_MAJOR_LAYOUT, device=device, memory_config=ttnn.DRAM_MEMORY_CONFIG | ||
) | ||
tensor = ttnn.to_layout(tensor, ttnn.TILE_LAYOUT, dtype=output_dtype, device=device) | ||
end = time.time() | ||
logger.info(f"Time taken to convert to tensor using device-tilizer: {end-start}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters