1
0
Fork 0

rm import docstrings

deepcrayon
Jeff Moe 2023-12-06 18:38:13 -07:00
parent f81204dea3
commit df9e8aa28f
8 changed files with 0 additions and 162 deletions

View File

@ -1,13 +1,3 @@
"""
This script imports necessary modules and functions for the tinygrad library.
1. `from __future__ import annotations` is used to enable postponed evaluation of type hints.
2. `import numpy as np` imports the NumPy library for numerical operations.
3. `from collections import defaultdict` imports the defaultdict function from the collections module, which creates a dictionary with a default value.
4. The next line contains various types and type checking utilities imported from the typing module.
5. `import importlib, inspect, functools, pathlib, time, re, ctypes` imports several modules for different purposes like dynamic loading of modules (importlib), inspection of live objects (inspect), higher-order functions (functools), file system paths (pathlib), time operations (time), regular expressions (re) and foreign function interface (ctypes).
"""
from __future__ import annotations
import numpy as np
from collections import defaultdict

View File

@ -1,26 +1,3 @@
"""
Module for TinyGrad, a minimal gradient-based optimizer.
**os**: Provides a way to interact with the operating system depending on your applications needs. For example, file handling, process management, etc.
**atexit**: This module allows you to define functions that will be automatically called when the Python interpreter exits. It can be used to perform some cleanup tasks before the termination of a script.
**functools**: A standard library module that provides higher-order functions that work on callable objects, i.e., functions or methods. This includes things like `reduce()` and `partial()`.
**collections.defaultdict**: A dictionary subclass which calls a factory function to supply missing values.
**typing.Dict/List**: These are typing utilities from the Python standard library, used here for type hinting. Dict represents a dictionary, List represents a list.
**tinygrad.ops**: This module contains classes and functions that define operations on tensors in TinyGrad. It includes classes for unary, binary, reduce, movement, load, buffer, and ternary operations, as well as the base Op class and LazyOp class.
**tinygrad.helpers**: This module contains helper functions and variables used across different parts of TinyGrad. It includes GlobalCounters for tracking counts, getenv to retrieve environment variables, and dedup to remove duplicates from a list.
**tinygrad.codegen.linearizer**: This module is responsible for linearizing operations on tensors in TinyGrad. It includes classes for unary operations (UOps) and unary operation (UOp).
**tinygrad.shape.shapetracker**: This module contains the ShapeTracker class, which is responsible for tracking the shape of tensors in TinyGrad.
**tinygrad.shape.symbolic**: This module contains the NumNode class, which represents a node in the computation graph and allows for symbolic differentiation and manipulation of mathematical expressions involving tensor operations.
"""
import os, atexit, functools
from collections import defaultdict
from typing import Dict, List

View File

@ -1,47 +1,3 @@
"""
This script imports various modules for different functionalities. Some of the known module functions are described below:
**os**: Provides a way to interact with the operating system dependent functionality like reading or writing files, handling paths etc.
**functools**: It offers higher-order functions like higher order functions and decorators which can be used for advanced functionalities.
**platform**: This module provides various functions to get details about the platform such as system, hardware, Python implementation etc.
**time**: It offers functions to work with time in a variety of formats and perform time-related operations.
**re**: Provides support for regular expressions in Python. Regular expressions are a powerful and flexible method of pattern matching in strings.
**contextlib**: Offers a way to manage context managers as contexts. Context managers allow you to allocate and release resources precisely when you want to.
**operator**: This module provides a set of efficient functions for performing element-wise operations on arrays.
**hashlib**: It offers a variety of hash functions such as SHA1, SHA256 etc., which are used for secure data transmission and storage.
**pickle**: This module implements binary protocols for serializing and de-serializing Python objects using Pickle format.
**sqlite3**: Provides an interface to SQLite databases. SQLite is a software library that provides a relational database management system.
**cProfile**: It offers deterministic profiling of Python programs, measuring the time each function takes to execute.
**pstats**: Offers various functions to read and manage data from profiling files generated by cProfile.
**tempfile**: Provides temporary file creation functionality which can be used for various purposes like sharing data between processes etc.
**pathlib**: This module offers an object-oriented way of working with filesystem paths.
**string**: It provides various functions to manipulate strings, including string constants and a collection of all ASCII characters.
**ctypes**: Provides C compatible data types for Python and allows calling functions in shared libraries written in languages like C or C++.
**numpy**: This module offers an array object which is a powerful n-dimensional array object which is very fast and flexible.
**urllib**: It provides tools to open URLs, with support for HTTP, FTP etc., and to work with the HTTP request and response messages.
**tqdm**: Provides a fast, extensible progress bar for loops.
**typing**: Offers runtime type checking in Python 3.5+. Allows specifying variable types, return types of functions etc.
"""
from __future__ import annotations
import os, functools, platform, time, re, contextlib, operator, hashlib, pickle, sqlite3, cProfile, pstats, tempfile, pathlib, string, ctypes
import numpy as np

View File

@ -1,16 +1,3 @@
"""
**sys**: The sys module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter.
**math**: The math module supplies some mathematical functions and constants.
**typing**: This module supplies several helper classes and functions for type hints.
**weakref**: The weakref module is useful for creating weak references to objects, which can be useful for creating caches where the garbage collector is allowed to delete the cached values if memory is needed elsewhere.
**numpy**: NumPy is a Python library that stands for 'Numerical Python'. It is a library for the Python programming language, adding support for large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays.
**tinygrad.helpers**: This module contains helper functions used throughout TinyGrad.
"""
from __future__ import annotations
import sys, math
from typing import Callable, Optional, Tuple, Union, List, Dict, Any, cast, Mapping, Set

View File

@ -1,18 +1,3 @@
"""
**math**: The math module provides access to the mathematical functions defined by the C standard library.
**typing**: This module provides runtime type checking for Python. It allows you to specify what the expected types are for function arguments and return values.
**tinygrad.helpers**: This module contains helper functions used throughout TinyGrad, such as argsort (for sorting arrays) and DType (for data types).
**tinygrad.ops**: This module contains various operations like UnaryOps (single input, single output operations), BinaryOps (two input, single output operations), TernaryOps (three input, single output operations), and ReduceOps (operations that reduce an array to a single value).
**tinygrad.tensor**: This module contains the main Tensor class of TinyGrad, which is used for mathematical operations on multi-dimensional arrays. It also includes the Function class, which represents a function within the computational graph.
**tinygrad.lazy**: The lazy module provides a LazyBuffer class that allows you to create buffers that are lazily initialized, meaning they don't consume memory until they are first used.
**tinygrad.shape.symbolic**: This module contains symbolic integer functions, such as sint (symbolic integer).
"""
import math
from typing import Tuple, Optional, cast
from tinygrad.helpers import argsort, DType

View File

@ -1,18 +1,3 @@
"""
**annotations**: Import annotations from the future to use them in type hints.
**typing**: Import typing module for type hinting and checking.
**functools**: Import functools for higher-order functions like partial application and function composition.
**enum**: Import enum for creating enumeration classes.
**tinygrad.helpers**: Import helper functions from tinygrad library to perform operations such as product calculation, data type handling, and deduplication.
**tinygrad.shape.symbolic**: Import Variable class from tinygrad library which is used to represent variables in symbolic computations.
**dataclasses**: Import dataclass decorator for creating simple classes with a lot of boilerplate removed.
"""
from __future__ import annotations
from typing import TYPE_CHECKING, Union, Type, Tuple, Any, List, Dict, Callable, Mapping
import functools

View File

@ -1,17 +1,3 @@
"""
This script imports necessary modules from the tinygrad library and defines a class or function (c).
**tinygrad.ops**: Imports classes and functions related to operations in the tinygrad library. LoadOps is for loading operations, ScheduleItem is for scheduling items in a graph.
**tinygrad.device**: Imports Device for managing hardware devices, Buffer for handling memory buffers, BufferCopy for copying data between buffers, and JITRunner for just-in-time compiling of code.
**tinygrad.graph**: Imports log_schedule_item for logging schedule items in a graph and print_tree for printing the structure of a tree.
**tinygrad.helpers**: Imports prod for finding the product of elements in an iterable.
**tinygrad.shape.symbolic**: Imports Variable for working with symbolic variables in tensor computations.
"""
from typing import List, Dict, Optional
from tinygrad.ops import LoadOps, ScheduleItem
from tinygrad.device import Device, Buffer, BufferCopy, JITRunner

View File

@ -1,31 +1,3 @@
"""
**tinygrad**: A minimal implementation of a neural computer using tiny modules.
* **time, math**: Basic Python libraries for time and mathematical operations.
* **typing**: Provides runtime type checking in Python.
* **collections.defaultdict**: Constructs an ordered dictionary that is resilient to key errors.
* **functools.partialmethod**: A method that's a partial application of a function, i.e., a method with some of its arguments filled in.
* **itertools.accumulate**: Returns accumulated sums, or accumulated results of other binary functions.
* **numpy**: A library for the Python programming language, adding support for large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays.
* **tinygrad.helpers**: Contains utility functions for handling data types, argument fixes, making pairs, and more.
* **tinygrad.lazy**: Implements lazy evaluation of operations, which can be useful in creating efficient computational graphs.
* **tinygrad.ops**: Contains core mathematical operations for the neural computer.
* **tinygrad.device**: Provides classes for managing hardware devices and memory buffers.
* **tinygrad.shape.symbolic**: Implements symbolic shape calculations.
* **tinygrad.realize**: Realizes a computation schedule by executing it on a device.
"""
# inspired by https://github.com/karpathy/micrograd/blob/master/micrograd/engine.py
from __future__ import annotations
import time, math