forked from tinygrad/tinygrad
move DEBUG to helpers
This commit is contained in:
@@ -10,9 +10,9 @@ import triton # type: ignore # noqa: F401
|
||||
import triton.language as tl # type: ignore # noqa: F401
|
||||
|
||||
from typing import Union, Tuple, Optional, Dict
|
||||
from tinygrad.ops import UnaryOps, BinaryOps, ReduceOps, LazyOp, Op, ExplicitExecAST, DEBUG, GlobalCounters
|
||||
from tinygrad.ops import UnaryOps, BinaryOps, ReduceOps, LazyOp, Op, ExplicitExecAST, GlobalCounters
|
||||
from tinygrad.shape import ShapeTracker
|
||||
from tinygrad.helpers import prod
|
||||
from tinygrad.helpers import prod, DEBUG
|
||||
from tinygrad.runtime.cuda import CLBuffer
|
||||
from tinygrad.ast import ASTKernel
|
||||
|
||||
|
||||
+2
-1
@@ -2,7 +2,8 @@ from typing import Callable, List, Tuple
|
||||
import itertools
|
||||
from tinygrad.lazy import Device
|
||||
from tinygrad.tensor import Tensor
|
||||
from tinygrad.ops import DEBUG, GlobalCounters
|
||||
from tinygrad.helpers import DEBUG
|
||||
from tinygrad.ops import GlobalCounters
|
||||
|
||||
class TinyJit:
|
||||
def __init__(self, fxn):
|
||||
|
||||
@@ -8,8 +8,7 @@ from tinygrad.ops import LazyOp, ReduceOps, BinaryOps, UnaryOps, MovementOps
|
||||
from tinygrad.shape import ShapeTracker, View, ZeroView
|
||||
from tinygrad.llops.ops_gpu import GPUBuffer, CLASTKernel
|
||||
from tinygrad.runtime.opencl import OSX_TIMING_RATIO
|
||||
from tinygrad.ops import DEBUG
|
||||
from tinygrad.helpers import getenv
|
||||
from tinygrad.helpers import getenv, DEBUG
|
||||
from extra.lib_test_ast import test_ast
|
||||
|
||||
import pickle, dbm
|
||||
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
import numpy as np
|
||||
from tinygrad.tensor import Tensor
|
||||
from tinygrad.helpers import prod
|
||||
from tinygrad.ops import DEBUG
|
||||
from tinygrad.helpers import getenv
|
||||
from tinygrad.helpers import getenv, DEBUG
|
||||
from onnx.mapping import TENSOR_TYPE_TO_NP_TYPE
|
||||
|
||||
ONNXLIMIT = getenv("ONNXLIMIT", -1)
|
||||
|
||||
+2
-2
@@ -7,8 +7,8 @@ except ImportError:
|
||||
nx = None # graph won't work
|
||||
from collections import defaultdict
|
||||
from typing import Dict, List, Optional
|
||||
from tinygrad.ops import DeviceBuffer, DEBUG, UnaryOps, BinaryOps, ReduceOps, MovementOps, ProcessingOps, LoadOps, Op, OpType, LazyOp, get_buffers, get_lazyops
|
||||
from tinygrad.helpers import getenv
|
||||
from tinygrad.ops import DeviceBuffer, UnaryOps, BinaryOps, ReduceOps, MovementOps, ProcessingOps, LoadOps, Op, OpType, LazyOp, get_buffers, get_lazyops
|
||||
from tinygrad.helpers import getenv, DEBUG
|
||||
|
||||
GRAPH, PRUNEGRAPH, GRAPHPATH = getenv("GRAPH", 0), getenv("PRUNEGRAPH", 0), getenv("GRAPHPATH", "/tmp/net")
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ class Timing(object):
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
def getenv(key, default=0): return type(default)(os.getenv(key, default))
|
||||
DEBUG = getenv("DEBUG", 0)
|
||||
|
||||
def reduce_shape(shape, axis): return tuple(1 if i in axis else shape[i] for i in range(len(shape)))
|
||||
def shape_to_axis(old_shape, new_shape):
|
||||
|
||||
+2
-2
@@ -2,9 +2,9 @@ from __future__ import annotations
|
||||
from typing import Optional, Tuple, Union, List, Dict, Any, ClassVar, Type
|
||||
import sys, weakref, os, importlib, inspect
|
||||
from weakref import WeakValueDictionary
|
||||
from tinygrad.helpers import ConvArgs, prod
|
||||
from tinygrad.helpers import ConvArgs, prod, DEBUG
|
||||
from tinygrad.shape import ShapeTracker
|
||||
from tinygrad.ops import DeviceBuffer, UnaryOps, BinaryOps, ReduceOps, MovementOps, ProcessingOps, LoadOps, OpType, LazyOp, get_buffers, map_buffers, DEBUG, GenericExecAST
|
||||
from tinygrad.ops import DeviceBuffer, UnaryOps, BinaryOps, ReduceOps, MovementOps, ProcessingOps, LoadOps, OpType, LazyOp, get_buffers, map_buffers, GenericExecAST
|
||||
from tinygrad.graph import log_op
|
||||
from tinygrad.helpers import getenv
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from __future__ import annotations
|
||||
import numpy as np
|
||||
from typing import List, Tuple, Optional, Dict, Union, Set, Final, Callable
|
||||
from tinygrad.helpers import prod
|
||||
from tinygrad.ops import DEBUG, UnaryOps, BinaryOps, ReduceOps, MovementOps, LazyOp, Op, ExplicitExecAST, GlobalCounters
|
||||
from tinygrad.helpers import prod, DEBUG
|
||||
from tinygrad.ops import UnaryOps, BinaryOps, ReduceOps, MovementOps, LazyOp, Op, ExplicitExecAST, GlobalCounters
|
||||
from tinygrad.ast import ASTKernel, Token, Types
|
||||
from tinygrad.lazy import IMAGE
|
||||
from tinygrad.shape import ShapeTracker
|
||||
|
||||
@@ -2,13 +2,13 @@ from __future__ import annotations
|
||||
import math
|
||||
import functools
|
||||
from typing import Tuple, Union, Dict, Any, List, ClassVar, Optional
|
||||
from tinygrad.helpers import prod
|
||||
from tinygrad.helpers import prod, DEBUG
|
||||
from tinygrad.shape import ShapeTracker
|
||||
from tinygrad.ops import LazyOp
|
||||
from tinygrad.ast import ASTKernel
|
||||
import ctypes
|
||||
import numpy as np
|
||||
from tinygrad.ops import DEBUG, UnaryOps, BinaryOps, ReduceOps, ExplicitExecAST
|
||||
from tinygrad.ops import UnaryOps, BinaryOps, ReduceOps, ExplicitExecAST
|
||||
from tinygrad.runtime.llvm import LLVM, ir
|
||||
from tinygrad.shape.symbolic import Variable, NumNode, MulNode, DivNode, ModNode, GeNode, LtNode, SumNode, AndNode
|
||||
|
||||
|
||||
@@ -5,9 +5,6 @@ from typing import Union, Type, NamedTuple, Tuple, Any, List, ClassVar, Optional
|
||||
import functools, operator
|
||||
from tinygrad.helpers import prod
|
||||
from tinygrad.shape import ShapeTracker
|
||||
from tinygrad.helpers import getenv
|
||||
|
||||
DEBUG = getenv("DEBUG", 0)
|
||||
|
||||
# these are the llops your accelerator must implement, along with toCpu
|
||||
# the Enum class doesn't work with mypy, this is static. sorry it's ugly
|
||||
|
||||
@@ -5,7 +5,7 @@ import hashlib
|
||||
import subprocess
|
||||
from collections import defaultdict
|
||||
from typing import List, Final, Dict
|
||||
from tinygrad.ops import DEBUG
|
||||
from tinygrad.helpers import DEBUG
|
||||
import platform
|
||||
OSX = platform.system() == "Darwin"
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@ import pycuda.autoprimaryctx # type: ignore # pylint: disable=unused-import # no
|
||||
import pycuda.driver as cuda # type: ignore
|
||||
from pycuda.compiler import compile # type: ignore
|
||||
import numpy as np
|
||||
from tinygrad.ops import DEBUG, GlobalCounters
|
||||
from tinygrad.helpers import DEBUG
|
||||
from tinygrad.ops import GlobalCounters
|
||||
|
||||
class CLBuffer:
|
||||
def __init__(self, size): self._cl = cuda.mem_alloc(size)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from typing import ClassVar
|
||||
from tinygrad.helpers import getenv
|
||||
from tinygrad.ops import DEBUG, GlobalCounters
|
||||
from tinygrad.helpers import getenv, DEBUG
|
||||
from tinygrad.ops import GlobalCounters
|
||||
import hashlib
|
||||
import time
|
||||
import ctypes
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
import Metal, Cocoa, libdispatch # type: ignore
|
||||
import numpy as np
|
||||
from typing import List, Any
|
||||
from tinygrad.ops import DEBUG, GlobalCounters
|
||||
from tinygrad.helpers import prod, getenv
|
||||
from tinygrad.ops import GlobalCounters
|
||||
from tinygrad.helpers import prod, getenv, DEBUG
|
||||
import subprocess
|
||||
|
||||
METAL_XCODE = getenv("METAL_XCODE")
|
||||
|
||||
@@ -3,8 +3,8 @@ import numpy as np
|
||||
import pyopencl as cl # type: ignore
|
||||
from typing import Dict, Optional, Tuple, List, ClassVar, Final
|
||||
from collections import defaultdict
|
||||
from tinygrad.ops import DEBUG, GlobalCounters
|
||||
from tinygrad.helpers import getenv
|
||||
from tinygrad.ops import GlobalCounters
|
||||
from tinygrad.helpers import getenv, DEBUG
|
||||
|
||||
OSX = platform.system() == "Darwin"
|
||||
OSX_TIMING_RATIO = (125/3) if OSX else 1.0 # see test/external_osx_profiling.py to determine this ratio. it's in like GPU clocks or something
|
||||
|
||||
@@ -2,12 +2,9 @@
|
||||
from __future__ import annotations
|
||||
import functools
|
||||
from typing import Tuple, Union, List, Optional
|
||||
from tinygrad.helpers import prod, getenv
|
||||
from tinygrad.helpers import prod, DEBUG
|
||||
from tinygrad.shape.symbolic import Variable
|
||||
|
||||
# TODO: fix DEBUG import
|
||||
DEBUG = getenv("DEBUG", 0)
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
def to_shape_strides(shape:Tuple[int, ...], strides:Tuple[int, ...]) -> List[Tuple[int, int]]:
|
||||
assert len(shape) == len(strides)
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import numpy as np
|
||||
from tinygrad.helpers import prod, argfix, make_pair, getenv
|
||||
from typing import List, Tuple, Callable, Optional, ClassVar, Type, Union
|
||||
from tinygrad.lazy import Device, LazyBuffer
|
||||
from tinygrad.ops import DEBUG
|
||||
from tinygrad.helpers import DEBUG
|
||||
|
||||
# An instantiation of the Function is the Context
|
||||
class Function:
|
||||
|
||||
Reference in New Issue
Block a user