Skip to content

Commit

Permalink
Remove mock_ttnn
Browse files Browse the repository at this point in the history
  • Loading branch information
ayerofieiev-tt committed Jul 6, 2024
1 parent 6b661cc commit 71e81be
Show file tree
Hide file tree
Showing 20 changed files with 25 additions and 181 deletions.
2 changes: 1 addition & 1 deletion tests/lowering/eltwise/test_add.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import torch
import torch_ttnn
import unittest
from torch_ttnn import ttnn
import ttnn
from torch.fx.passes.dialect.common.cse_pass import CSEPass


Expand Down
2 changes: 1 addition & 1 deletion tests/lowering/matmul/test_only_add_matmul.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import torch
import torch_ttnn
import unittest
from torch_ttnn import ttnn
import ttnn

from torch_ttnn.utils import check_with_pcc

Expand Down
2 changes: 1 addition & 1 deletion tests/lowering/tensor_manipulation/test_expand.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import torch
import torch_ttnn
import unittest
from torch_ttnn import ttnn
import ttnn
import tt_lib
from torch_ttnn.utils import (
DummyTtnnRowMajorLayout,
Expand Down
2 changes: 1 addition & 1 deletion tests/lowering/test_if.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import torch
import torch_ttnn
import unittest
from torch_ttnn import ttnn
import ttnn
from torch.fx.passes.dialect.common.cse_pass import CSEPass


Expand Down
2 changes: 1 addition & 1 deletion tests/lowering/test_more_ops.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import torch
import torch_ttnn
import unittest
from torch_ttnn import ttnn
import ttnn
import tt_lib

from torch_ttnn.utils import check_with_pcc
Expand Down
2 changes: 1 addition & 1 deletion tests/models/bert/test_bert.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import torch
import torch_ttnn
import unittest
from torch_ttnn import ttnn
import ttnn
import collections

# Load model directly
Expand Down
2 changes: 1 addition & 1 deletion tests/models/resnet/test_resnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import torchvision
import torch_ttnn
import unittest
from torch_ttnn import ttnn
import ttnn
import collections


Expand Down
2 changes: 1 addition & 1 deletion tests/test_fall_back.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import torch
import torch_ttnn
import unittest
from torch_ttnn import ttnn
import ttnn

from torch_ttnn.utils import check_with_pcc

Expand Down
2 changes: 1 addition & 1 deletion tests/tools/test_stats.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import shutil
import torch
from torch_ttnn import torch_stat
import torch_stat
import unittest
import json
from torch.fx.passes.dialect.common.cse_pass import CSEPass
Expand Down
12 changes: 7 additions & 5 deletions torch_ttnn/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from .backend import backend
from .backend import TorchTtnnOption
from torch_ttnn.backend import backend
from torch_ttnn.backend import TorchTtnnOption

try:
import ttnn
except ImportError:
print("ttnn is not installed, use mock_ttnn instead")
from . import mock_ttnn as ttnn
except ImportError as e:
print(
"ttnn is not installed. Run `python3 -m pip install -r requirements.txt` or `python3 -m pip install -r requirements-dev.txt` if you are developing the compiler"
)
raise e
7 changes: 1 addition & 6 deletions torch_ttnn/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@
from typing import List
import torch._dynamo
from functorch.compile import make_boxed_func
import ttnn

torch._dynamo.config.suppress_errors = False
torch._dynamo.config.verbose = True

try:
import ttnn
except ImportError:
print("ttnn is not installed, use mock_ttnn instead")
from . import mock_ttnn as ttnn


# The backend for torch.compile that converts a graph to use ttnn.
# The "option" parameter is a dict that contains one key "torch_ttnn_option".
Expand Down
6 changes: 1 addition & 5 deletions torch_ttnn/fx_graphviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
import math
from collections import defaultdict

try:
import ttnn
except ImportError:
print("ttnn is not installed, use mock_ttnn instead")
from torch_tnn import mock_ttnn as ttnn
import ttnn


def _tensor_weight(t):
Expand Down
116 changes: 0 additions & 116 deletions torch_ttnn/mock_ttnn.py

This file was deleted.

6 changes: 1 addition & 5 deletions torch_ttnn/passes/graphviz_pass.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import torch
from torch_ttnn import fx_graphviz

try:
import ttnn
except ImportError:
print("ttnn is not installed, use mock_ttnn instead")
from torch_ttnn import mock_ttnn as ttnn
import ttnn

from torch.fx.passes.infra.pass_base import PassBase, PassResult

Expand Down
6 changes: 1 addition & 5 deletions torch_ttnn/passes/lowering/add_data_move_pass.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import torch
import ttnn
from torch_ttnn.utils import (
DummyTtnnUint32,
DummyTtnnRowMajorLayout,
DummyTtnnTileLayout,
DummyDevice,
)

try:
import ttnn
except ImportError:
print("ttnn is not installed, use mock_ttnn instead")
from torch_ttnn import mock_ttnn as ttnn

from torch.fx.passes.infra.pass_base import PassBase, PassResult

Expand Down
7 changes: 1 addition & 6 deletions torch_ttnn/passes/lowering/eliminate_data_move_pass.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import torch

try:
import ttnn
except ImportError:
print("ttnn is not installed, use mock_ttnn instead")
from torch_ttnn import mock_ttnn as ttnn
import ttnn

from torch.fx.passes.infra.pass_base import PassBase, PassResult

Expand Down
7 changes: 1 addition & 6 deletions torch_ttnn/passes/lowering/permute_reshape_tuple.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import torch

try:
import ttnn
except ImportError:
print("ttnn is not installed, use mock_ttnn instead")
from torch_ttnn import mock_ttnn as ttnn
import ttnn

from torch.fx.passes.infra.pass_base import PassBase, PassResult

Expand Down
7 changes: 1 addition & 6 deletions torch_ttnn/passes/lowering/to_tt_pass.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import torch
import ttnn
from torch_ttnn.utils import (
GraphCleanup,
DummyTtlTensorTensorMemoryLayoutInterleaved,
Expand All @@ -9,12 +10,6 @@
)
import numpy as np

try:
import ttnn
except ImportError:
print("ttnn is not installed, use mock_ttnn instead")
from torch_ttnn import mock_ttnn as ttnn

from torch.fx.passes.infra.pass_base import PassBase, PassResult
import torch.fx.traceback as fx_traceback

Expand Down
7 changes: 1 addition & 6 deletions torch_ttnn/patterns/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
# This file may not be needed anymore.

import torch

try:
import ttnn
except ImportError:
print("ttnn is not installed, use mock_ttnn instead")
from torch_ttnn import mock_ttnn as ttnn
import ttnn


# NOTE(yoco) The name `add` must be the same as the name of the function.
Expand Down
7 changes: 1 addition & 6 deletions torch_ttnn/patterns/mm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
# This file may not be needed anymore.

import torch

try:
import ttnn
except ImportError:
print("ttnn is not installed, use mock_ttnn instead")
from torch_ttnn import mock_ttnn as ttnn
import ttnn


# NOTE(yoco) The name `matmul` must be the same as the name of the function.
Expand Down

0 comments on commit 71e81be

Please sign in to comment.