Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc] Improve ODOP doc structure #5089

Merged
merged 1 commit into from
Jun 6, 2022
Merged
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
8 changes: 4 additions & 4 deletions docs/lang/articles/advanced/odop.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ programming** (ODOP).

## Data-oriented classes

### Introduction

If you need to define a **Taichi kernel** as a Python class member function, please decorate the class with a `@ti.data_oriented` decorator. You can then define `ti.kernel`s and `ti.func`s in your *data-oriented* Python class.

:::note
Expand Down Expand Up @@ -110,8 +112,6 @@ print(a.y) # [ 5. 13. 21. 29.]
```


## Integrating features from the Python classes

### Inheritance of data-oriented classes

The *data-oriented* property will be automatically carried beyond the Python class inheriting. This means the **Taichi Kernel** could be called while any of the ancestor classes are decorated by the `@ti.data_oriented` decorator.
Expand Down Expand Up @@ -167,7 +167,7 @@ c = BaseClass()
# The two lines above will trigger a kernel define error, since class c is not decorated by @ti.data_oriented
```

### Python-built-in-decorators
### Python built-in decorators

Common decorators that are pre-built in Python, `@staticmethod`[^1] and `@classmethod`[^2], could decorate to a **Taichi kernel** in *data-oriented* classes.

Expand Down Expand Up @@ -345,7 +345,7 @@ get_area() # 201.062...

### Notes on struct classes
- Inheritance of struct classes is not implemented.
- While functions attached to a struct with the `@ti.struct_class` decorator is convenient and encouraged, it is actually possible to associated a function to structs with the older method of defining structs. As mentioned above, the two methods for defining a struct type are identical in their output. To do this, use the `__struct_method` argument with the `ti.types.struct` call:
- While functions attached to a struct with the `@ti.struct_class` decorator is convenient and encouraged, it is actually possible to associate a function to structs with the older method of defining structs. As mentioned above, the two methods for defining a struct type are identical in their output. To do this, use the `__struct_methods` argument with the `ti.types.struct` call:

```python
@ti.func
Expand Down