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

[docs] Optimize tutorial code in operator_custom_with_taichi.ipynb of documentations #546

Merged
merged 4 commits into from
Nov 16, 2023
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
24 changes: 12 additions & 12 deletions docs/tutorial_advanced/operator_custom_with_taichi.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Operator Customization with Numba"
"# Operator Customization with Taichi"
]
},
{
Expand All @@ -18,7 +18,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Brain dynamics is sparse and event-driven, however, proprietary operators for brain dynamics are not well abstracted and summarized. As a result, we are often faced with the need to customize operators. In this tutorial, we will explore how to customize brain dynamics operators using ti.\n",
"Brain dynamics is sparse and event-driven, however, proprietary operators for brain dynamics are not well abstracted and summarized. As a result, we are often faced with the need to customize operators. In this tutorial, we will explore how to customize brain dynamics operators using taichi.\n",
"\n",
"Start by importing the relevant Python package."
]
Expand Down Expand Up @@ -242,11 +242,11 @@
" vector: ti.types.ndarray(ndim=1), \n",
" weight: ti.types.ndarray(ndim=1), \n",
" out: ti.types.ndarray(ndim=1)):\n",
" weight_0 = weight[0]\n",
" ti.loop_config(block_dim=64)\n",
" for i, j in ti.ndrange(indices.shape[0], indices.shape[1]):\n",
" if vector[i]:\n",
" out[indices[i, j]] += weight_0\n",
" weight_0 = weight[0]\n",
" ti.loop_config(block_dim=64)\n",
" for ij in ti.grouped(indices):\n",
" if vector[ij[0]]:\n",
" out[ij[1]] += weight_0\n",
"\n",
"prim = bm.XLACustomOp(cpu_kernel=event_ell_cpu, gpu_kernel=event_ell_gpu)\n",
"\n",
Expand Down Expand Up @@ -503,11 +503,11 @@
" vector: ti.types.ndarray(ndim=1), \n",
" weight: ti.types.ndarray(ndim=1), \n",
" out: ti.types.ndarray(ndim=1)):\n",
" weight_0 = weight[0]\n",
" ti.loop_config(block_dim=64)\n",
" for i, j in ti.ndrange(indices.shape[0], indices.shape[1]):\n",
" if vector[i]:\n",
" out[indices[i, j]] += weight_0\n",
" weight_0 = weight[0]\n",
" ti.loop_config(block_dim=64)\n",
" for ij in ti.grouped(indices):\n",
" if vector[ij[0]]:\n",
" out[ij[1]] += weight_0\n",
"\n",
"prim = bm.XLACustomOp(cpu_kernel=event_ell_cpu, gpu_kernel=event_ell_gpu)\n",
"\n",
Expand Down