From c21d3be4fcfabdeb436b582d453a9b543d1ed7fe Mon Sep 17 00:00:00 2001 From: Zhao Liang Date: Tue, 27 Sep 2022 16:22:19 +0800 Subject: [PATCH 1/5] Update syntax.md --- docs/lang/articles/kernels/syntax.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/lang/articles/kernels/syntax.md b/docs/lang/articles/kernels/syntax.md index 605ad64d40bb8..77d1e9c15385f 100644 --- a/docs/lang/articles/kernels/syntax.md +++ b/docs/lang/articles/kernels/syntax.md @@ -6,8 +6,8 @@ sidebar_position: 1 Embedded in Python, Taichi resembles Python in language syntax. To differentiate Taichi code from native Python code, we use the two decorators `@ti.kernel` and `@ti.func`: -+ Functions decorated with `@ti.kernel` are called Taichi kernels (or kernels for short). They serve as the entry points where Taichi begins to take over the tasks, and they *must* be called directly by Python code. -+ Functions decorated with `@ti.func` are called Taichi functions. They serve as the building blocks of kernels and can *only* be called by kernels or other Taichi functions. ++ Functions decorated with `@ti.kernel` are called Taichi kernels (or kernels for short). They serve as the entry points where Taichi begins to take over the tasks, and they *must* be called directly by Python code. Usually the users prepare their work in native Python (for example, read data from the disk and preprocess them) and then call kernels to let Taichi do the actual computation-intensive job. ++ Functions decorated with `@ti.func` are called Taichi functions. They serve as the building blocks of kernels and can *only* be called by kernels or other Taichi functions. Like ordinary Python functions, you can factor your task into several Taichi functions to make your code more readable and reuse them in different kernels. Let's see an example: @@ -82,7 +82,7 @@ You can define multiple kernels in your program. They are mutually *independent* :::caution WARNING -You must *not* call a kernel from inside another kernel or from inside a Taichi function. You can only call a kernel directly or from inside a native Python function. In other words, you can only call a kernel from inside the Python scope. +You can only call a kernel directly or from inside a native Python function. You must *not* call a kernel from inside another kernel or from inside a Taichi function. In other words, you can only call a kernel from inside the Python scope. ::: @@ -92,7 +92,7 @@ You must *not* call a kernel from inside another kernel or from inside a Taichi A kernel can take multiple arguments. However, you *cannot* pass any arbitrary Python object to a kernel because Python objects can be highly dynamic and may hold data unrecognized by Taichi's compiler. -The argument types accepted by kernels are scalars, `ti.Matrix/ti.Vector` (In Taichi, vectors are essentially matrices), `ti.types.ndarray()` and `ti.template()`. You can easily pass data from the Python scope to the Taichi scope. +The argument types accepted by kernels are scalars, `ti.Matrix/ti.Vector` (vectors are essentially matrices), `ti.types.ndarray()` and `ti.template()`. These types are defined in the `ti.types` module (see [type system](../type_system/type.md) for more information). You can easily pass data from the Python scope to the Taichi scope. It should be noted that scalars and `ti.Matrix` are passed by value, while `ti.types.ndarray()` and `ti.template()` are passed by reference. In the latter case, any modification to the arguments in the called function also affects the original values. From 9c6f89b0bb20725733ecb511b4cca6c359b277f9 Mon Sep 17 00:00:00 2001 From: Zhao Liang Date: Tue, 27 Sep 2022 16:24:46 +0800 Subject: [PATCH 2/5] Update syntax.md --- docs/lang/articles/kernels/syntax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/lang/articles/kernels/syntax.md b/docs/lang/articles/kernels/syntax.md index 77d1e9c15385f..bc0d765804ae0 100644 --- a/docs/lang/articles/kernels/syntax.md +++ b/docs/lang/articles/kernels/syntax.md @@ -6,7 +6,7 @@ sidebar_position: 1 Embedded in Python, Taichi resembles Python in language syntax. To differentiate Taichi code from native Python code, we use the two decorators `@ti.kernel` and `@ti.func`: -+ Functions decorated with `@ti.kernel` are called Taichi kernels (or kernels for short). They serve as the entry points where Taichi begins to take over the tasks, and they *must* be called directly by Python code. Usually the users prepare their work in native Python (for example, read data from the disk and preprocess them) and then call kernels to let Taichi do the actual computation-intensive job. ++ Functions decorated with `@ti.kernel` are called Taichi kernels (or kernels for short). They serve as the entry points where Taichi begins to take over the tasks, and they *must* be called directly by Python code. Usually the users prepare their work in native Python (for example, read data from the disk and preprocess them) and then call kernels to invoke Taichi to take over the actual computation-intensive job. + Functions decorated with `@ti.func` are called Taichi functions. They serve as the building blocks of kernels and can *only* be called by kernels or other Taichi functions. Like ordinary Python functions, you can factor your task into several Taichi functions to make your code more readable and reuse them in different kernels. Let's see an example: From d2305720b828f73fcaf35a7a4121fb3956aa9423 Mon Sep 17 00:00:00 2001 From: Zhao Liang Date: Tue, 27 Sep 2022 23:40:05 +0800 Subject: [PATCH 3/5] Update docs/lang/articles/kernels/syntax.md Co-authored-by: Vissidarte-Herman <93570324+Vissidarte-Herman@users.noreply.github.com> --- docs/lang/articles/kernels/syntax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/lang/articles/kernels/syntax.md b/docs/lang/articles/kernels/syntax.md index bc0d765804ae0..b51d4d4e8224b 100644 --- a/docs/lang/articles/kernels/syntax.md +++ b/docs/lang/articles/kernels/syntax.md @@ -92,7 +92,7 @@ You can only call a kernel directly or from inside a native Python function. You A kernel can take multiple arguments. However, you *cannot* pass any arbitrary Python object to a kernel because Python objects can be highly dynamic and may hold data unrecognized by Taichi's compiler. -The argument types accepted by kernels are scalars, `ti.Matrix/ti.Vector` (vectors are essentially matrices), `ti.types.ndarray()` and `ti.template()`. These types are defined in the `ti.types` module (see [type system](../type_system/type.md) for more information). You can easily pass data from the Python scope to the Taichi scope. +The argument types accepted by kernels are scalars, `ti.Matrix/ti.Vector` (vectors are essentially matrices), `ti.types.ndarray()` and `ti.template()`. These types are defined in the `ti.types` module (see the [Type System](../type_system/type.md) for more information). You can easily pass data from the Python scope to the Taichi scope. It should be noted that scalars and `ti.Matrix` are passed by value, while `ti.types.ndarray()` and `ti.template()` are passed by reference. In the latter case, any modification to the arguments in the called function also affects the original values. From 865da6ab88119b0ef0b7fd9d1e158a75e935074c Mon Sep 17 00:00:00 2001 From: Zhao Liang Date: Tue, 27 Sep 2022 23:40:17 +0800 Subject: [PATCH 4/5] Update docs/lang/articles/kernels/syntax.md Co-authored-by: Vissidarte-Herman <93570324+Vissidarte-Herman@users.noreply.github.com> --- docs/lang/articles/kernels/syntax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/lang/articles/kernels/syntax.md b/docs/lang/articles/kernels/syntax.md index b51d4d4e8224b..785ee20c2623b 100644 --- a/docs/lang/articles/kernels/syntax.md +++ b/docs/lang/articles/kernels/syntax.md @@ -82,7 +82,7 @@ You can define multiple kernels in your program. They are mutually *independent* :::caution WARNING -You can only call a kernel directly or from inside a native Python function. You must *not* call a kernel from inside another kernel or from inside a Taichi function. In other words, you can only call a kernel from inside the Python scope. +You can only call a kernel directly or from inside a native Python function. You must *not* call a kernel from inside another kernel or from inside a Taichi function. To put it differently, you can only call a kernel from inside the Python scope. ::: From 7d5ea415f0107e7d7bb78d44db8e4474978ebbfa Mon Sep 17 00:00:00 2001 From: Zhao Liang Date: Tue, 27 Sep 2022 23:40:46 +0800 Subject: [PATCH 5/5] Update docs/lang/articles/kernels/syntax.md Co-authored-by: Vissidarte-Herman <93570324+Vissidarte-Herman@users.noreply.github.com> --- docs/lang/articles/kernels/syntax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/lang/articles/kernels/syntax.md b/docs/lang/articles/kernels/syntax.md index 785ee20c2623b..4910b050d0a85 100644 --- a/docs/lang/articles/kernels/syntax.md +++ b/docs/lang/articles/kernels/syntax.md @@ -7,7 +7,7 @@ sidebar_position: 1 Embedded in Python, Taichi resembles Python in language syntax. To differentiate Taichi code from native Python code, we use the two decorators `@ti.kernel` and `@ti.func`: + Functions decorated with `@ti.kernel` are called Taichi kernels (or kernels for short). They serve as the entry points where Taichi begins to take over the tasks, and they *must* be called directly by Python code. Usually the users prepare their work in native Python (for example, read data from the disk and preprocess them) and then call kernels to invoke Taichi to take over the actual computation-intensive job. -+ Functions decorated with `@ti.func` are called Taichi functions. They serve as the building blocks of kernels and can *only* be called by kernels or other Taichi functions. Like ordinary Python functions, you can factor your task into several Taichi functions to make your code more readable and reuse them in different kernels. ++ Functions decorated with `@ti.func` are called Taichi functions. They are the building blocks of kernels and can *only* be called by a kernels or another Taichi function. Just as you do with normal Python functions, you can split your tasks into multiple Taichi functions to make your code more readable and reuse them in different kernels. Let's see an example: