mirror of
https://github.com/MLSysBook/TinyTorch.git
synced 2026-05-04 12:42:34 -05:00
refactor: Standardize imports across modules 10-17 to match 01-09
Enforce consistent import pattern across all modules: - Direct imports from tinytorch.core.* (no fallbacks) - Remove all sys.path.append manipulations - Remove try/except import fallbacks - Remove mock/dummy class fallbacks Fixed modules: - Module 10 (tokenization): Removed try/except fallback - Module 12 (attention): Removed sys.path.append for tensor/layers - Module 15 (profiling): Removed sys.path + mock Tensor/Linear/Conv2d - Module 16 (acceleration): Removed hardcoded path + importlib + mock Tensor - Module 17 (quantization): Removed sys.path + disabled fallback block All modules now follow the same pattern as modules 01-09: from tinytorch.core.tensor import Tensor from tinytorch.core.layers import Linear # etc. No development fallbacks - assume tinytorch package is installed.
This commit is contained in:
@@ -67,27 +67,9 @@ from collections import defaultdict
|
||||
import gc
|
||||
|
||||
# Import our TinyTorch components for profiling
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '01_tensor'))
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '03_layers'))
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '09_spatial'))
|
||||
|
||||
# For testing purposes - in real package these would be proper imports
|
||||
try:
|
||||
from tensor_dev import Tensor
|
||||
from layers_dev import Linear, Sequential
|
||||
from spatial_dev import Conv2d
|
||||
except ImportError:
|
||||
# Fallback - create minimal implementations for testing
|
||||
class Tensor:
|
||||
def __init__(self, data):
|
||||
self.data = np.array(data)
|
||||
self.shape = self.data.shape
|
||||
def __mul__(self, other):
|
||||
return Tensor(self.data * other.data)
|
||||
def sum(self):
|
||||
return Tensor(np.sum(self.data))
|
||||
from tinytorch.core.tensor import Tensor
|
||||
from tinytorch.core.layers import Linear
|
||||
from tinytorch.core.spatial import Conv2d
|
||||
|
||||
# %% [markdown]
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user