From 66c4b0a22cd2d2d83ae45faadc0157e5b4f33925 Mon Sep 17 00:00:00 2001 From: pranavm Date: Tue, 14 Jan 2025 13:32:54 -0800 Subject: [PATCH] Various minor changes to public documentation --- tripy/README.md | 107 +++++++++--------- .../00-introduction-to-tripy.md | 2 +- tripy/nvtripy/types.py | 4 +- 3 files changed, 56 insertions(+), 57 deletions(-) diff --git a/tripy/README.md b/tripy/README.md index 1686c2d8c..129148525 100644 --- a/tripy/README.md +++ b/tripy/README.md @@ -1,8 +1,8 @@ # Tripy: A Python Programming Model For TensorRT -[**Installation**](#installation) -| [**Getting Started**](#getting-started) +[**Quick Start**](#quick-start) +| [**Installation**](#installation) | [**Examples**](https://github.com/NVIDIA/TensorRT-Incubator/tree/main/tripy/examples) | [**Notebooks**](https://github.com/NVIDIA/TensorRT-Incubator/tree/main/tripy/notebooks) | [**Contributing**](https://github.com/NVIDIA/TensorRT-Incubator/blob/main/tripy/CONTRIBUTING.md) @@ -17,53 +17,63 @@ a deep learning inference compiler. What you can expect: -- **High Performance:** Leveraging [TensorRT](https://developer.nvidia.com/tensorrt)'s optimization capabilties. +- **High performance** by leveraging [TensorRT](https://developer.nvidia.com/tensorrt)'s optimization capabilties. +- An **intuitive API** that follows conventions of the ecosystem. +- **Debuggability** with features like **eager mode** to interactively debug mistakes. +- **Excellent error messages** that are informative and actionable. +- **Friendly documentation** that is comprehensive but concise, with code examples. -- **Intuitive API:** A familiar API that follows conventions of the ecosystem. -- **Debuggability:** **Eager mode** to interactively debug mistakes. +## Quick Start -- **Excellent Error Messages**: Informative and actionable. +See the +[Introduction To Tripy](https://nvidia.github.io/TensorRT-Incubator/pre0_user_guides/00-introduction-to-tripy.html) +guide for details: -- **Friendly Documentation**: Comprehensive but concise, with code examples. + +- **Defining** a model: -Code is worth 1,000 words: + ```py + class Model(tp.Module): + def __init__(self): + self.conv = tp.Conv(in_channels=1, out_channels=1, kernel_dims=[3, 3]) - -```py -# Define our model: -class Model(tp.Module): - def __init__(self): - self.conv = tp.Conv(in_channels=1, out_channels=1, kernel_dims=[3, 3]) - - def __call__(self, x): - x = self.conv(x) - x = tp.relu(x) - return x - - -# Initialize the model and load weights: -model = Model() -model.load_state_dict( - { - "conv.weight": tp.ones((1, 1, 3, 3)), - "conv.bias": tp.ones((1,)), - } -) - -inp = tp.ones((1, 1, 4, 4)) - -# Eager mode: -eager_out = model(inp) - -# Compiled mode: -compiled_model = tp.compile( - model, - args=[tp.InputInfo(shape=(1, 1, 4, 4), dtype=tp.float32)], -) - -compiled_out = compiled_model(inp) -``` + def __call__(self, x): + x = self.conv(x) + x = tp.relu(x) + return x + ``` + +- **Initializing** it: + + ```py + model = Model() + model.load_state_dict( + { + "conv.weight": tp.ones((1, 1, 3, 3)), + "conv.bias": tp.ones((1,)), + } + ) + + dummy_input = tp.ones((1, 1, 4, 4)) + ``` + +- Executing in **eager mode**: + + ```py + eager_out = model(dummy_input) + ``` + +- **Compiling** and executing: + + ```py + compiled_model = tp.compile( + model, + args=[tp.InputInfo(shape=(1, 1, 4, 4), dtype=tp.float32)], + ) + + compiled_out = compiled_model(dummy_input) + ``` @@ -106,14 +116,3 @@ For the latest changes, build Tripy wheels from source: python3 -c "import nvtripy as tp; x = tp.ones((5,), dtype=tp.int32); assert x.tolist() == [1] * 5" ``` - - -## Getting Started - -- **Start with**: - [Introduction To Tripy](https://nvidia.github.io/TensorRT-Incubator/pre0_user_guides/00-introduction-to-tripy.html) - -Other guides: - -- [Compiling For Better Performance](https://nvidia.github.io/TensorRT-Incubator/pre0_user_guides/02-compiler.html) -- [Quantization](https://nvidia.github.io/TensorRT-Incubator/pre0_user_guides/01-quantization.html) diff --git a/tripy/docs/pre0_user_guides/00-introduction-to-tripy.md b/tripy/docs/pre0_user_guides/00-introduction-to-tripy.md index e0ca40786..edd5b9bf4 100644 --- a/tripy/docs/pre0_user_guides/00-introduction-to-tripy.md +++ b/tripy/docs/pre0_user_guides/00-introduction-to-tripy.md @@ -5,7 +5,7 @@ a deep learning inference compiler. ## API Semantics -Unlike TensorRT's graph-based semantics, Tripy uses a functional style: +Unlike TensorRT's graph-based semantics, Tripy uses a **functional** style: ```py # doc: no-print-locals diff --git a/tripy/nvtripy/types.py b/tripy/nvtripy/types.py index 8389fbc64..f34cacb99 100644 --- a/tripy/nvtripy/types.py +++ b/tripy/nvtripy/types.py @@ -33,7 +33,7 @@ module=sys.modules[__name__], symbol="TensorLike", doc=""" - A Tripy :class:`Tensor` or a Python number that can be automatically converted into one. + A :class:`nvtripy.Tensor` or a Python number that can be automatically converted into one. """, )(Union["nvtripy.Tensor", numbers.Number]) @@ -53,6 +53,6 @@ module=sys.modules[__name__], symbol="ShapeLike", doc=""" - A shape of a :class:`Tensor` . + A shape of a :class:`nvtripy.Tensor` . """, )(Sequence[IntLike])