Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/api/compiler/TvarantTracer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# TvarantTracer

```python
class torch_tvarant.compiler.TvarantTracer
```

::: torch_tvarant.compiler.TvarantTracer
options:
show_root_heading: false
show_root_toc_entry: false
show_source: true
show_signature: true
show_signature_annotations: true
separate_signature: true
merge_init_into_class: true
members_order: source
docstring_section_style: table
heading_level: 2
18 changes: 18 additions & 0 deletions docs/api/compiler/compile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# compile

```python
torch_tvarant.compiler.compile(module, *, dynamic=False) → Callable
```

::: torch_tvarant.compiler.compile
options:
show_root_heading: false
show_root_toc_entry: false
show_source: true
show_signature: true
show_signature_annotations: true
separate_signature: true
merge_init_into_class: true
members_order: source
docstring_section_style: table
heading_level: 2
18 changes: 18 additions & 0 deletions docs/api/compiler/compile_fx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# compile_fx

```python
torch_tvarant.compiler.compile_fx(gm, example_inputs=None) → GraphModule
```

::: torch_tvarant.compiler.compile_fx
options:
show_root_heading: false
show_root_toc_entry: false
show_source: true
show_signature: true
show_signature_annotations: true
separate_signature: true
merge_init_into_class: true
members_order: source
docstring_section_style: table
heading_level: 2
18 changes: 18 additions & 0 deletions docs/api/compiler/fuse_gemm_epilogue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# fuse_gemm_epilogue

```python
torch_tvarant.compiler.fuse_gemm_epilogue(gm) → GraphModule
```

::: torch_tvarant.compiler.fuse_gemm_epilogue
options:
show_root_heading: false
show_root_toc_entry: false
show_source: true
show_signature: true
show_signature_annotations: true
separate_signature: true
merge_init_into_class: true
members_order: source
docstring_section_style: table
heading_level: 2
18 changes: 18 additions & 0 deletions docs/api/compiler/fuse_pointwise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# fuse_pointwise

```python
torch_tvarant.compiler.fuse_pointwise(gm) → GraphModule
```

::: torch_tvarant.compiler.fuse_pointwise
options:
show_root_heading: false
show_root_toc_entry: false
show_source: true
show_signature: true
show_signature_annotations: true
separate_signature: true
merge_init_into_class: true
members_order: source
docstring_section_style: table
heading_level: 2
20 changes: 20 additions & 0 deletions docs/api/compiler/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# torch_tvarant.compiler

Graph compiler that fuses GEMM epilogues and pointwise chains for inference on
`device="tvarant"`.

```python
import torch_tvarant
compiled = torch_tvarant.compiler.compile(model)
y = compiled(x)
```

| API | Summary |
|---|---|
| [`compile`](compile.md) | Compile a module for inference |
| [`compile_fx`](compile_fx.md) | Fuse an FX graph |
| [`trace_module`](trace_module.md) | FX-trace with inlined Linear/activations |
| [`fuse_gemm_epilogue`](fuse_gemm_epilogue.md) | Fuse mm/linear + act into `linear_act` |
| [`fuse_pointwise`](fuse_pointwise.md) | Collapse pointwise chains |
| [`register`](register.md) | Register Dynamo backend `"tvarant"` |
| [`TvarantTracer`](TvarantTracer.md) | Custom FX tracer |
18 changes: 18 additions & 0 deletions docs/api/compiler/register.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# register

```python
torch_tvarant.compiler.register() → None
```

::: torch_tvarant.compiler.register
options:
show_root_heading: false
show_root_toc_entry: false
show_source: true
show_signature: true
show_signature_annotations: true
separate_signature: true
merge_init_into_class: true
members_order: source
docstring_section_style: table
heading_level: 2
18 changes: 18 additions & 0 deletions docs/api/compiler/trace_module.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# trace_module

```python
torch_tvarant.compiler.trace_module(module) → GraphModule
```

::: torch_tvarant.compiler.trace_module
options:
show_root_heading: false
show_root_toc_entry: false
show_source: true
show_signature: true
show_signature_annotations: true
separate_signature: true
merge_init_into_class: true
members_order: source
docstring_section_style: table
heading_level: 2
28 changes: 20 additions & 8 deletions docs/api/index.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
# API reference

This section mirrors a PyTorch-style API layout for **torch_tvarant**.
PyTorch-style reference for **torch_tvarant**. Each entry is a dedicated page
with signature, parameters, and examples.

| Page | Contents |
|---|---|
| [torch.tvarant](torch.md) | Device module helpers + Python package / compiler (auto-generated) |
| [Supported ops](ops.md) | ATen and custom ops registered for `PrivateUse1` |
| [Kernels](kernels.md) | Host and OpenCL kernel catalog |
| [C++](cpp.md) | Extension layout, `TORCH_LIBRARY_IMPL`, adding ops |
## torch.tvarant

Unimplemented ATen ops fall back to CPU; see [Supported ops](ops.md).
Device module — [`torch.tvarant` overview](torch/index.md)

- [`is_available`](torch/is_available.md) · [`device_count`](torch/device_count.md) · [`backend`](torch/backend.md)
- [`set_device`](torch/set_device.md) · [`synchronize`](torch/synchronize.md)
- [`manual_seed`](torch/manual_seed.md) · [`get_rng_state`](torch/get_rng_state.md) · …

## torch_tvarant.compiler

- [`compile`](compiler/compile.md) · [`compile_fx`](compiler/compile_fx.md)
- [`trace_module`](compiler/trace_module.md) · [`register`](compiler/register.md)
- [Compiler overview](compiler/index.md)

## Supported ops

- [Ops index](ops/index.md) — `relu`, `add`, `mm`, `linear`, `linear_act`, …
- [Kernels](kernels.md) — host / OpenCL catalog
- [C++](cpp.md) — extension layout & `TORCH_LIBRARY_IMPL`
46 changes: 0 additions & 46 deletions docs/api/ops.md

This file was deleted.

33 changes: 33 additions & 0 deletions docs/api/ops/add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# add

```python
torch.add(input, other, *, alpha=1, out=None) → Tensor
input + other
```

Adds `other`, scaled by `alpha`, to `input`:

$$
\text{out}_i = \text{input}_i + \alpha \times \text{other}_i
$$

## Parameters

- **input** (`Tensor`) – First operand (Tvarant).
- **other** (`Tensor or Number`) – Second operand (broadcasting).
- **alpha** (`Number`) – Multiplier for `other`. Default: `1`.

## Shape

- Input: $(*)$
- Output: broadcast shape of `input` and `other`

## Example

```python
y = torch.add(a, b, alpha=1.0) # or a + b
```

---

[← All supported ops](index.md)
27 changes: 27 additions & 0 deletions docs/api/ops/clone.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# clone / contiguous

```python
Tensor.clone(memory_format=torch.preserve_format) → Tensor
Tensor.contiguous(memory_format=torch.contiguous_format) → Tensor
```

Materialize a copy (`clone`) or a contiguous storage (`contiguous`) on Tvarant via `_copy_from`.

## Parameters

- **memory_format** (`torch.memory_format`) – Desired memory format.

## Shape

- Output: same logical shape as input

## Example

```python
y = x.clone()
c = x.t().contiguous()
```

---

[← All supported ops](index.md)
27 changes: 27 additions & 0 deletions docs/api/ops/embedding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# embedding

```python
torch.nn.functional.embedding(input, weight, ...) → Tensor
```

Lookup embeddings. Indices should be convertible to int32 on the Tvarant path.

## Parameters

- **input** (`LongTensor`) – Token indices.
- **weight** (`Tensor`) – Embedding table `(V, D)` on Tvarant.

## Shape

- Input: $(*)$
- Output: $(*, D)$

## Example

```python
e = torch.nn.functional.embedding(tokens, weight)
```

---

[← All supported ops](index.md)
28 changes: 28 additions & 0 deletions docs/api/ops/empty.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# empty

```python
torch.empty(*size, *, dtype=None, layout=torch.strided, device=None, pin_memory=False, memory_format=torch.contiguous_format) → Tensor
```

Returns a tensor filled with uninitialized data on `device="tvarant"`.

## Parameters

- **size** (`int...`) – Size of the returned tensor.
- **dtype** (`torch.dtype, optional`) – Desired data type. Defaults to the global default (prefer `float32`).
- **device** (`torch.device, optional`) – Use `"tvarant"` / `"tvarant:0"`.
- **memory_format** (`torch.memory_format, optional`) – Memory format for the result.

## Shape

- Output: $(\textit{size})$

## Example

```python
x = torch.empty(2, 3, device='tvarant', dtype=torch.float32)
```

---

[← All supported ops](index.md)
42 changes: 42 additions & 0 deletions docs/api/ops/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Supported ops

ATen and custom ops registered for `PrivateUse1` (`device="tvarant"`).
Unlisted ops **fall back to CPU** (tensors are copied as needed).

Click an op for signature, parameters, shape, and examples.

## Factories & memory

| Op | Page |
|---|---|
| `empty` / `empty_strided` | [empty](empty.md) |
| `zeros` / `ones` / `full` | [zeros / ones / full](zeros.md) |
| `clone` / `contiguous` | [clone / contiguous](clone.md) |

## Pointwise

| Op | Page |
|---|---|
| `add` | [add](add.md) |
| `mul` | [mul](mul.md) |
| `sub` | [sub](sub.md) |
| `relu` | [relu](relu.md) |
| `silu` | [silu](silu.md) |
| `neg` / `abs` / `exp` / `sqrt` / … | [unary](neg.md) |

## Linear algebra & NN

| Op | Page |
|---|---|
| `mm` / `addmm` / `matmul` / `bmm` | [mm family](mm.md) |
| `linear` | [linear](linear.md) |
| `softmax` | [softmax](softmax.md) |
| `layer_norm` | [layer_norm](layer_norm.md) |
| `embedding` | [embedding](embedding.md) |

## Custom (`torch.ops.tvarant`)

| Op | Page |
|---|---|
| `linear_act` | [linear_act](linear_act.md) |
| `pointwise` | [pointwise](pointwise.md) |
Loading
Loading