From a436b9f4c1b88120863b4d1793b64b236caef3ef Mon Sep 17 00:00:00 2001 From: Kian-Meng Ang Date: Wed, 29 Jun 2022 14:03:31 +0800 Subject: [PATCH] [Doc] Fix typos (#5283) * Fix typos * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- CMakeLists.txt | 2 +- ci/Dockerfile.ubuntu.18.04 | 2 +- ci/Dockerfile.ubuntu.18.04.cpu | 2 +- ci/Dockerfile.ubuntu.20.04 | 2 +- ci/Dockerfile.ubuntu.20.04.cpu | 2 +- ci/Dockerfile_generator.py | 2 +- cmake/TaichiCXXFlags.cmake | 2 +- cmake/TaichiCore.cmake | 2 +- cmake/TaichiExamples.cmake | 2 +- docs/design/llvm_sparse_runtime.md | 4 +- docs/lang/articles/advanced/layout.md | 8 +- docs/lang/articles/advanced/performance.md | 2 +- docs/lang/articles/advanced/sparse.md | 2 +- .../contribution/contributor_guide.md | 2 +- .../lang/articles/contribution/dev_install.md | 4 +- docs/lang/articles/contribution/write_test.md | 2 +- docs/lang/articles/faq.md | 2 +- docs/lang/articles/misc/cli_utilities.md | 2 +- docs/lang/articles/misc/debugging.md | 2 +- docs/lang/articles/misc/export_results.md | 4 +- docs/lang/articles/misc/global_settings.md | 2 +- docs/lang/articles/misc/internal.md | 2 +- docs/rfcs/20220413-aot-for-all-snode.md | 4 +- external/include/json.hpp | 22 +- external/include/miniz.h | 2 +- external/include/stb_image.h | 2 +- external/include/stb_image_write.h | 2 +- external/include/stb_truetype.h | 12 +- misc/prtags.json | 2 +- python/taichi/_funcs.py | 2 +- python/taichi/_main.py | 6 +- python/taichi/_snode/fields_builder.py | 2 +- python/taichi/aot/utils.py | 2 +- .../examples/features/io/export_mesh.py | 4 +- .../examples/ggui_examples/fem128_ggui.py | 2 +- .../examples/ggui_examples/mpm128_ggui.py | 2 +- .../taichi/examples/rendering/cornell_box.py | 2 +- python/taichi/examples/simulation/euler.py | 2 +- python/taichi/examples/simulation/fem128.py | 2 +- .../simulation/initial_value_problem.py | 4 +- python/taichi/examples/simulation/mpm128.py | 2 +- python/taichi/lang/_ndrange.py | 2 +- python/taichi/lang/ast/ast_transformer.py | 4 +- python/taichi/lang/impl.py | 4 +- python/taichi/lang/matrix.py | 4 +- python/taichi/lang/struct.py | 6 +- python/taichi/math/mathimpl.py | 6 +- python/taichi/profiler/kernel_metrics.py | 2 +- python/taichi/profiler/kernel_profiler.py | 6 +- python/taichi/tools/image.py | 2 +- python/taichi/types/compound_types.py | 2 +- python/taichi/ui/gui.py | 2 +- python/taichi/ui/ui.py | 2 +- python/taichi/ui/utils.py | 2 +- scripts/run_clang_tidy.sh | 2 +- taichi/analysis/arithmetic_interpretor.h | 4 +- .../gather_uniquely_accessed_pointers.cpp | 2 +- taichi/aot/module_builder.h | 2 +- taichi/backends/cuda/cuda_driver.cpp | 3 +- taichi/backends/cuda/cuda_driver.h | 2 +- taichi/backends/cuda/cuda_types.h | 2 +- taichi/backends/cuda/cupti_toolkit.cpp | 2 +- taichi/backends/vulkan/vulkan_api.h | 2 +- taichi/backends/vulkan/vulkan_device.cpp | 2 +- taichi/codegen/spirv/kernel_utils.h | 2 +- taichi/codegen/spirv/spirv_types.cpp | 2 +- taichi/common/core.h | 4 +- taichi/common/dict.h | 3 +- taichi/common/interface.h | 242 +++++++++--------- taichi/common/serialization.h | 2 +- taichi/gui/android.cpp | 2 +- taichi/ir/analysis.h | 2 +- taichi/ir/expression_ops.h | 2 +- taichi/ir/frontend_ir.cpp | 2 +- taichi/math/array_2d.h | 2 +- taichi/math/linalg.h | 4 +- taichi/platform/mac/objc_api.h | 2 +- taichi/program/kernel.h | 4 +- taichi/program/ndarray.cpp | 2 +- taichi/program/program.cpp | 2 +- taichi/python/export_lang.cpp | 2 +- taichi/runtime/gfx/runtime.cpp | 4 +- taichi/runtime/llvm/llvm_context.h | 4 +- taichi/runtime/llvm/llvm_runtime_executor.cpp | 2 +- .../llvm/runtime_module/internal_functions.h | 2 +- taichi/runtime/metal/kernel_manager.cpp | 4 +- taichi/runtime/metal/kernel_utils.h | 2 +- taichi/system/traceback.cpp | 2 +- taichi/transforms/auto_diff.cpp | 2 +- taichi/transforms/type_check.cpp | 2 +- taichi/ui/backends/vulkan/gui.cpp | 2 +- tests/cpp/codegen/refine_coordinates_test.cpp | 2 +- tests/python/test_customized_grad.py | 2 +- tests/python/test_ggui.py | 6 +- 94 files changed, 260 insertions(+), 258 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 41f394e9b758c..55fcf2fe2faae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,7 +72,7 @@ endif() if (WIN32) # For `Debug` configs MSVC links to a debuggable runtime by default which has - # symbol conflicts with the prebuilt LLVM in `Release`. We shoule be providing + # symbol conflicts with the prebuilt LLVM in `Release`. We should be providing # prebuilt LLVMs for both `Debug` and `Release` but LLVM 10 cannot be built by # MSVC in `Debug` config because MSVC would try to fill uninitialize memory # with `0xCC` but it too breaks `LLVMTableGen` which is depended on by almost diff --git a/ci/Dockerfile.ubuntu.18.04 b/ci/Dockerfile.ubuntu.18.04 index de7c5597bf579..d39f15fc82630 100644 --- a/ci/Dockerfile.ubuntu.18.04 +++ b/ci/Dockerfile.ubuntu.18.04 @@ -51,7 +51,7 @@ RUN tar xf cmake-3.20.5-linux-x86_64.tar.gz && \ rm cmake-3.20.5-linux-x86_64.tar.gz ENV PATH="/cmake-3.20.5-linux-x86_64/bin:$PATH" -# Intall LLVM 10 +# Install LLVM 10 WORKDIR / # Make sure this URL gets updated each time there is a new prebuilt bin release RUN wget https://github.com/taichi-dev/taichi_assets/releases/download/llvm10_linux_patch2/taichi-llvm-10.0.0-linux.zip diff --git a/ci/Dockerfile.ubuntu.18.04.cpu b/ci/Dockerfile.ubuntu.18.04.cpu index 2bec9b4053d30..6c545669d22c7 100644 --- a/ci/Dockerfile.ubuntu.18.04.cpu +++ b/ci/Dockerfile.ubuntu.18.04.cpu @@ -27,7 +27,7 @@ RUN wget https://github.com/Kitware/CMake/releases/download/v3.20.5/cmake-3.20.5 rm cmake-3.20.5-linux-x86_64.tar.gz ENV PATH="/cmake-3.20.5-linux-x86_64/bin:$PATH" -# Intall LLVM 10 +# Install LLVM 10 WORKDIR / # Make sure this URL gets updated each time there is a new prebuilt bin release RUN wget https://github.com/taichi-dev/taichi_assets/releases/download/llvm10_linux_patch2/taichi-llvm-10.0.0-linux.zip && \ diff --git a/ci/Dockerfile.ubuntu.20.04 b/ci/Dockerfile.ubuntu.20.04 index d01352eec0cd4..1dfaeda77d7ec 100644 --- a/ci/Dockerfile.ubuntu.20.04 +++ b/ci/Dockerfile.ubuntu.20.04 @@ -52,7 +52,7 @@ RUN tar xf cmake-3.20.5-linux-x86_64.tar.gz && \ rm cmake-3.20.5-linux-x86_64.tar.gz ENV PATH="/cmake-3.20.5-linux-x86_64/bin:$PATH" -# Intall LLVM 10 +# Install LLVM 10 WORKDIR / # Make sure this URL gets updated each time there is a new prebuilt bin release RUN wget https://github.com/taichi-dev/taichi_assets/releases/download/llvm10_linux_patch2/taichi-llvm-10.0.0-linux.zip diff --git a/ci/Dockerfile.ubuntu.20.04.cpu b/ci/Dockerfile.ubuntu.20.04.cpu index 23d228faa9500..49e8d68397728 100644 --- a/ci/Dockerfile.ubuntu.20.04.cpu +++ b/ci/Dockerfile.ubuntu.20.04.cpu @@ -23,7 +23,7 @@ RUN tar xf cmake-3.20.5-linux-x86_64.tar.gz && \ rm cmake-3.20.5-linux-x86_64.tar.gz ENV PATH="/cmake-3.20.5-linux-x86_64/bin:$PATH" -# Intall LLVM 10 +# Install LLVM 10 WORKDIR / # Make sure this URL gets updated each time there is a new prebuilt bin release RUN wget https://github.com/taichi-dev/taichi_assets/releases/download/llvm10_linux_patch2/taichi-llvm-10.0.0-linux.zip diff --git a/ci/Dockerfile_generator.py b/ci/Dockerfile_generator.py index c160722336162..5081ded586bc7 100644 --- a/ci/Dockerfile_generator.py +++ b/ci/Dockerfile_generator.py @@ -113,7 +113,7 @@ """ LLVM_BLOCK = """ -# Intall LLVM 10 +# Install LLVM 10 WORKDIR / # Make sure this URL gets updated each time there is a new prebuilt bin release RUN wget https://github.com/taichi-dev/taichi_assets/releases/download/llvm10_linux_patch2/taichi-llvm-10.0.0-linux.zip diff --git a/cmake/TaichiCXXFlags.cmake b/cmake/TaichiCXXFlags.cmake index cc2c573b21b00..0b73ac4324c2c 100644 --- a/cmake/TaichiCXXFlags.cmake +++ b/cmake/TaichiCXXFlags.cmake @@ -72,7 +72,7 @@ endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-private-field ") # [Global] By evaluating "constexpr", compiler throws a warning for functions known to be dead at compile time. - # However, some of these "constexpr" are debug flags and will be manually enabled upon debuging. + # However, some of these "constexpr" are debug flags and will be manually enabled upon debugging. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unneeded-internal-declaration ") endif () diff --git a/cmake/TaichiCore.cmake b/cmake/TaichiCore.cmake index c8c34b53272ab..c2508038c1f03 100644 --- a/cmake/TaichiCore.cmake +++ b/cmake/TaichiCore.cmake @@ -471,7 +471,7 @@ if(TI_WITH_PYTHON AND NOT TI_EMSCRIPTENED) # https://cmake.org/cmake/help/v3.13/command/target_link_libraries.html?highlight=target_link_libraries#linking-object-libraries target_link_libraries(${CORE_WITH_PYBIND_LIBRARY_NAME} PRIVATE ${CORE_LIBRARY_NAME}) - # TODO 4832: move some header dependencis to other targets, e.g., gui + # TODO 4832: move some header dependencies to other targets, e.g., gui target_include_directories(${CORE_WITH_PYBIND_LIBRARY_NAME} PRIVATE ${PROJECT_SOURCE_DIR} diff --git a/cmake/TaichiExamples.cmake b/cmake/TaichiExamples.cmake index 66d638d8600b5..db338944b9e7c 100644 --- a/cmake/TaichiExamples.cmake +++ b/cmake/TaichiExamples.cmake @@ -28,7 +28,7 @@ target_link_libraries(${EXAMPLES_NAME} PRIVATE metal_codegen ) -# TODO 4832: be specific on the header dependencis here, e.g., ir +# TODO 4832: be specific on the header dependencies here, e.g., ir target_include_directories(${EXAMPLES_NAME} PRIVATE ${PROJECT_SOURCE_DIR} diff --git a/docs/design/llvm_sparse_runtime.md b/docs/design/llvm_sparse_runtime.md index a2a6dc8fcf4bc..12d17fdb72dfb 100644 --- a/docs/design/llvm_sparse_runtime.md +++ b/docs/design/llvm_sparse_runtime.md @@ -199,7 +199,7 @@ i32 Dynamic_append(Ptr meta_, Ptr node_, i32 data) { 2. `chunk_strat` tracks the starting index of a given chunk, and always starts at `0` . `p_chunk_ptr` is initialized to the pointer to the first chunk. 3. Inside the `while` loop, checks if the given chunk slot is empty first, and allocates a new chunk if so. 4. Compares if the determined index `i` falls within the current chunk. - 1. If so, stores `data` into the corresponding slot in this chunk. Note that the first `sizeof(Ptr)` bytes are skiped: they are reserved to store the address of the next chunk. + 1. If so, stores `data` into the corresponding slot in this chunk. Note that the first `sizeof(Ptr)` bytes are skipped: they are reserved to store the address of the next chunk. 2. Otherwise, jumps to the next chunk. # Runtime @@ -290,7 +290,7 @@ i32 reserve_new_element() { } ``` -It increments `num_elements` to get the index of this new elment, and calculates the belonging chunk ID. Then it ensures that the chunk is actually allocated using [`touch_chunk()`](https://github.com/taichi-dev/taichi/blob/172cab8a57fcfc2d766fe2b7cd40af669dadf326/taichi/runtime/llvm/runtime.cpp#L1570-L1584): +It increments `num_elements` to get the index of this new element, and calculates the belonging chunk ID. Then it ensures that the chunk is actually allocated using [`touch_chunk()`](https://github.com/taichi-dev/taichi/blob/172cab8a57fcfc2d766fe2b7cd40af669dadf326/taichi/runtime/llvm/runtime.cpp#L1570-L1584): ```cpp void ListManager::touch_chunk(int chunk_id) { diff --git a/docs/lang/articles/advanced/layout.md b/docs/lang/articles/advanced/layout.md index 2bb3a78190715..034fe61195fe2 100644 --- a/docs/lang/articles/advanced/layout.md +++ b/docs/lang/articles/advanced/layout.md @@ -164,7 +164,7 @@ y = ti.field(ti.f32) ti.root.dense(ti.i, M).place(x, y) ``` -The memroy layout then becomes +The memory layout then becomes ``` # address: low .............................. high @@ -175,7 +175,7 @@ Here, `place` interleaves the elements of Taichi fields `x` and `y`. As previously introduced, the access methods to `x` and `y` remain the same for both AoS and SoA. Therefore, the data layout can be changed flexibly without revising the application logic. - + For better illustration, let's see an example of an 1D wave equation solver: ```python @@ -336,7 +336,7 @@ Actually, the above demonstrated `ti.root` statements are implemented with `Fiel By default, Taichi implicitly fits a field in a larger buffer with power-of-two dimensions. We take the power-of-two padding convention because it is widely adopted in computer graphics. The design enables fast indexing with bitwise arithmetic and better memory address alignment, while trading off memory occupations. -For example, a `(18, 65)` field is materialized with a `(32, 128)` buffer, which is acceptable. As field size grows, the padding strategy can be exaggeratedly unbearable: `(129, 6553600)` will be expanded to `(256, 6335600)`, which allocates considerable unsed blank memory. Therefore, Taichi provides the optional packed mode to allocate buffer that tightly fits the requested field shape. It is especially useful when memory usage is a major concern. +For example, a `(18, 65)` field is materialized with a `(32, 128)` buffer, which is acceptable. As field size grows, the padding strategy can be exaggeratedly unbearable: `(129, 6553600)` will be expanded to `(256, 6335600)`, which allocates considerable unused blank memory. Therefore, Taichi provides the optional packed mode to allocate buffer that tightly fits the requested field shape. It is especially useful when memory usage is a major concern. To leverage the packed mode, spcifify `packed` in `ti.init()` argument: @@ -350,4 +350,4 @@ ti.init(packed=True) a = ti.field(ti.i32, shape=(18, 65)) # no padding ``` -You might observe mild performance regression with the packed mode due to more complex adressing and memory alignment. Therefore, the packed mode should be specified only when memory capacity is a major concern. +You might observe mild performance regression with the packed mode due to more complex addressing and memory alignment. Therefore, the packed mode should be specified only when memory capacity is a major concern. diff --git a/docs/lang/articles/advanced/performance.md b/docs/lang/articles/advanced/performance.md index 011670ed380c3..bf470d3738aa8 100644 --- a/docs/lang/articles/advanced/performance.md +++ b/docs/lang/articles/advanced/performance.md @@ -109,7 +109,7 @@ see the [Fields (advanced)](layout.md) section. Taichi comes with a few optimizations that leverage the *fast memory* (e.g. CUDA shared memory, L1 cache) for performance optimization. The idea is straightforward: -Wherever possible, Taichi substitutes the access to the global memroy (slow) with +Wherever possible, Taichi substitutes the access to the global memory (slow) with that to the local one (fast), and writes the data in the local memory (e.g., CUDA shared memory) back to the global memory in the end. Such transformations preserve the semantics of the original program (will be explained later). diff --git a/docs/lang/articles/advanced/sparse.md b/docs/lang/articles/advanced/sparse.md index 2a9b4389e5c97..0800881d2a402 100644 --- a/docs/lang/articles/advanced/sparse.md +++ b/docs/lang/articles/advanced/sparse.md @@ -32,7 +32,7 @@ we will significantly save storage and computing power. The key to leveraging spatial sparsity is replacing *dense* grids with *sparse* grids. ::: -The traditional sparse spatial data stuctures are [Quadtrees](https://en.wikipedia.org/wiki/Quadtree) (2D) and +The traditional sparse spatial data structures are [Quadtrees](https://en.wikipedia.org/wiki/Quadtree) (2D) and [Octrees](https://en.wikipedia.org/wiki/Octree) (3D). Since dereferencing pointers is relatively costly on modern computer architectures, compared to quadtrees and octrees, it is more performance-friendly to use shallower trees with larger branching factors. [VDB](https://www.openvdb.org/) and [SPGrid](http://pages.cs.wisc.edu/~sifakis/papers/SPGrid.pdf) are such examples. In Taichi, programmers can compose data structures similar to VDB and SPGrid with SNodes. The advantages of Taichi sparse spatial data structures include diff --git a/docs/lang/articles/contribution/contributor_guide.md b/docs/lang/articles/contribution/contributor_guide.md index 9bab09dcc21de..c3337d4ab9296 100644 --- a/docs/lang/articles/contribution/contributor_guide.md +++ b/docs/lang/articles/contribution/contributor_guide.md @@ -327,7 +327,7 @@ The following examples can be found in [cmake/TaichiCXXFlags.cmake](https://gith set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nullability-completeness ") # [Global] By evaluating "constexpr", compiler throws a warning for functions known to be dead at compile time. -# However, some of these "constexpr" specifiers are debug flags and will be manually enabled upon debuging. +# However, some of these "constexpr" specifiers are debug flags and will be manually enabled upon debugging. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unneeded-internal-declaration ") ``` diff --git a/docs/lang/articles/contribution/dev_install.md b/docs/lang/articles/contribution/dev_install.md index 5ffd53ee68284..1c6901efea5ef 100644 --- a/docs/lang/articles/contribution/dev_install.md +++ b/docs/lang/articles/contribution/dev_install.md @@ -211,7 +211,7 @@ We provide pre-built, customized LLVM binaries. For now, Taichi supports LLVM 10 -Add an environment variable `LLVM_DIR` with value `` +Add an environment variable `LLVM_DIR` with value `` @@ -275,7 +275,7 @@ cmake --build . --target=INSTALL --config=Release ``` 1. Use Visual Studio 2017+ to build **LLVM.sln**. -2. Ensure that you use the **Release** configuration. After building the `INSTALL` project (under folde **CMakePredefinedTargets** in the Solution Explorer window). +2. Ensure that you use the **Release** configuration. After building the `INSTALL` project (under folder **CMakePredefinedTargets** in the Solution Explorer window). 3. If you use MSVC 2019+, ensure that you use **C++17** for the `INSTALL` project. 4. When the build completes, add an environment variable `LLVM_DIR` with value `/build/installed/lib/cmake/llvm`. diff --git a/docs/lang/articles/contribution/write_test.md b/docs/lang/articles/contribution/write_test.md index b26a1805d831b..d9e90c8bde1e4 100644 --- a/docs/lang/articles/contribution/write_test.md +++ b/docs/lang/articles/contribution/write_test.md @@ -279,7 +279,7 @@ Now, Taichi supports the following extensions: | async_mode | Asynchronous execution mode | | quant_basic | Basic operations in quantization | | quant | Full quantization functionalities | -| data64 | 64-bit data and arithmetics | +| data64 | 64-bit data and arithmetic | | adstack | For keeping the history of mutable local variables in autodiff| | bls | Block-local storage | | assertion | Run-time asserts in Taichi kernels | diff --git a/docs/lang/articles/faq.md b/docs/lang/articles/faq.md index b087f22d65024..a7ec30e1658fc 100755 --- a/docs/lang/articles/faq.md +++ b/docs/lang/articles/faq.md @@ -60,7 +60,7 @@ The `dynamic` SNode supports variable-length fields. It acts similarly to `std:: An alternative solution is to allocate a large enough `dense` field, with a corresponding 0-D field `field_len[None]` tracking its length. In practice, programs allocating memory using `dynamic` SNodes may be less efficient than using `dense` SNodes, due to dynamic data structure -maintainance overheads. +maintenance overheads. ::: ### How do I program on less structured data structures (such as graphs and tetrahedral meshes) in Taichi? diff --git a/docs/lang/articles/misc/cli_utilities.md b/docs/lang/articles/misc/cli_utilities.md index fcb8893b93265..b53ecc8f979df 100644 --- a/docs/lang/articles/misc/cli_utilities.md +++ b/docs/lang/articles/misc/cli_utilities.md @@ -5,7 +5,7 @@ sidebar_position: 6 # Command line utilities A successful installation of Taichi should add a CLI (Command-Line -Interface) to your system, which is helpful to perform several rountine +Interface) to your system, which is helpful to perform several routine tasks quickly. To invoke the CLI, please run `ti` or `python3 -m taichi`. diff --git a/docs/lang/articles/misc/debugging.md b/docs/lang/articles/misc/debugging.md index 80e8f58268737..906992e856173 100644 --- a/docs/lang/articles/misc/debugging.md +++ b/docs/lang/articles/misc/debugging.md @@ -302,7 +302,7 @@ AssertionError: ``` The error message can be verbose and scary. However, many stack frames reveal Taichi compiler implementation details, which are too noisy for debugging. -In current verison, you could choose to supress the level of traceback messages by setting `sys.tracebacklimit`, +In current version, you could choose to suppress the level of traceback messages by setting `sys.tracebacklimit`, which makes the stack traceback from Taichi-scope more intuitive: ```python {2} diff --git a/docs/lang/articles/misc/export_results.md b/docs/lang/articles/misc/export_results.md index e45a2654fa168..f07f3b7f56335 100644 --- a/docs/lang/articles/misc/export_results.md +++ b/docs/lang/articles/misc/export_results.md @@ -308,11 +308,11 @@ writer.add_faces(indices) - Add optional channels ```python -# Add custome vertex channel, the input should include a key, a supported datatype and, the data np.array +# Add custom vertex channel, the input should include a key, a supported datatype and, the data np.array vdata = np.random.rand(20) writer.add_vertex_channel("vdata1", "double", vdata) -# Add custome face channel +# Add custom face channel foo_data = np.zeros(12) writer.add_face_channel("foo_key", "foo_data_type", foo_data) # error! because "foo_data_type" is not a supported datatype. Supported ones are diff --git a/docs/lang/articles/misc/global_settings.md b/docs/lang/articles/misc/global_settings.md index ba501fb455b4c..a6bbc0a295780 100644 --- a/docs/lang/articles/misc/global_settings.md +++ b/docs/lang/articles/misc/global_settings.md @@ -66,7 +66,7 @@ are specified, then the one in the environment variable will :::note -If `ti.init` is called twice, then the configuation in first invocation +If `ti.init` is called twice, then the configuration in first invocation will be completely discarded, e.g.: ```python {1,3} diff --git a/docs/lang/articles/misc/internal.md b/docs/lang/articles/misc/internal.md index 692b50f26947f..b66020988f23d 100644 --- a/docs/lang/articles/misc/internal.md +++ b/docs/lang/articles/misc/internal.md @@ -314,7 +314,7 @@ index does the i-th virtual index** correspond to? Each `SNode` can have a different virtual-to-physical mapping. `physical_index_position[i] == -1` means the `i`-th virtual index does -not corrspond to any physical index in this `SNode`. +not correspond to any physical index in this `SNode`. `SNode` s in handy dense fields (i.e., `a = ti.field(ti.i32, shape=(128, 256, 512))`) have **trivial** diff --git a/docs/rfcs/20220413-aot-for-all-snode.md b/docs/rfcs/20220413-aot-for-all-snode.md index 7df4ae3834b8b..061608d2c5afd 100644 --- a/docs/rfcs/20220413-aot-for-all-snode.md +++ b/docs/rfcs/20220413-aot-for-all-snode.md @@ -46,7 +46,7 @@ While this is convenient for Python users, it imposes challenges for the deploym 1. Taichi fields are currently implemented as global variables. - This would result in the Taichi kernels being "not pure" and relying on implicit information. When saving such kernels into the AOT module, it is also necessary to save all the depdendant global states. Ideally, users should be able to create Taichi fields, and pass them into Taichi kernels as parameters. + This would result in the Taichi kernels being "not pure" and relying on implicit information. When saving such kernels into the AOT module, it is also necessary to save all the dependent global states. Ideally, users should be able to create Taichi fields, and pass them into Taichi kernels as parameters. 2. SNodes types are missing from the AOT module. @@ -143,7 +143,7 @@ The only change from the existing API is that, you will need to prepend the fiel There will be two ways to retrieve a field from a tree: -* By name: `add_field()` takes in a `name` parameter. After building a SNode tree, Taichi will generate an attribute for each registered field on that tree. This allows you to directly write `tr.x` to access the field named `'x'`. `name` serves as the unique identifer of the field in the tree. Note that when placing, it is the names being passed in. +* By name: `add_field()` takes in a `name` parameter. After building a SNode tree, Taichi will generate an attribute for each registered field on that tree. This allows you to directly write `tr.x` to access the field named `'x'`. `name` serves as the unique identifier of the field in the tree. Note that when placing, it is the names being passed in. * By field handle: You can also use the field handle returned by `add_field()` to access a field. Here's an example: ```py builder = ti.SNodeTreeBuilder() diff --git a/external/include/json.hpp b/external/include/json.hpp index fee999e14335a..a4c571c1df536 100644 --- a/external/include/json.hpp +++ b/external/include/json.hpp @@ -219,7 +219,7 @@ class exception : public std::exception /*! @brief exception indicating a parse error -This excpetion is thrown by the library when a parse error occurs. Parse errors +This exception is thrown by the library when a parse error occurs. Parse errors can occur during the deserialization of JSON text, CBOR, MessagePack, as well as when using JSON Patch. @@ -235,7 +235,7 @@ json.exception.parse_error.102 | parse error at 14: missing or wrong low surroga json.exception.parse_error.103 | parse error: code points above 0x10FFFF are invalid | Unicode supports code points up to 0x10FFFF. Code points above 0x10FFFF are invalid. json.exception.parse_error.104 | parse error: JSON patch must be an array of objects | [RFC 6902](https://tools.ietf.org/html/rfc6902) requires a JSON Patch document to be a JSON document that represents an array of objects. json.exception.parse_error.105 | parse error: operation must have string member 'op' | An operation of a JSON Patch document must contain exactly one "op" member, whose value indicates the operation to perform. Its value must be one of "add", "remove", "replace", "move", "copy", or "test"; other values are errors. -json.exception.parse_error.106 | parse error: array index '01' must not begin with '0' | An array index in a JSON Pointer ([RFC 6901](https://tools.ietf.org/html/rfc6901)) may be `0` or any number wihtout a leading `0`. +json.exception.parse_error.106 | parse error: array index '01' must not begin with '0' | An array index in a JSON Pointer ([RFC 6901](https://tools.ietf.org/html/rfc6901)) may be `0` or any number without a leading `0`. json.exception.parse_error.107 | parse error: JSON pointer must be empty or begin with '/' - was: 'foo' | A JSON Pointer must be a Unicode string containing a sequence of zero or more reference tokens, each prefixed by a `/` character. json.exception.parse_error.108 | parse error: escape character '~' must be followed with '0' or '1' | In a JSON Pointer, only `~0` and `~1` are valid escape sequences. json.exception.parse_error.109 | parse error: array index 'one' is not a number | A JSON Pointer array index must be a number. @@ -3285,7 +3285,7 @@ class parser } /*! - @brief the acutal acceptor + @brief the actual acceptor @invariant 1. The last token is not yet processed. Therefore, the caller of this function must make sure a token has been read. @@ -5227,7 +5227,7 @@ class binary_reader @return number of type @a NumberType - @note This function needs to respect the system's endianess, because + @note This function needs to respect the system's endianness, because bytes in CBOR and MessagePack are stored in network order (big endian) and therefore need reordering on little endian systems. @@ -5537,7 +5537,7 @@ class binary_reader /// the number of characters read std::size_t chars_read = 0; - /// whether we can assume little endianess + /// whether we can assume little endianness const bool is_little_endian = little_endianess(); }; @@ -6048,7 +6048,7 @@ class binary_writer @param[in] n number of type @a NumberType @tparam NumberType the type of the number - @note This function needs to respect the system's endianess, because bytes + @note This function needs to respect the system's endianness, because bytes in CBOR and MessagePack are stored in network order (big endian) and therefore need reordering on little endian systems. */ @@ -6069,7 +6069,7 @@ class binary_writer } private: - /// whether we can assume little endianess + /// whether we can assume little endianness const bool is_little_endian = binary_reader::little_endianess(); /// the output @@ -6579,7 +6579,7 @@ class serializer // check that the additional bytes are present assert(i + bytes < s.size()); - // to useĀ \uxxxx escaping, we first need to caluclate + // to useĀ \uxxxx escaping, we first need to calculate // the codepoint from the UTF-8 bytes int codepoint = 0; @@ -8278,7 +8278,7 @@ class basic_json @brief create a JSON value This is a "catch all" constructor for all compatible JSON types; that is, - types for which a `to_json()` method exsits. The constructor forwards the + types for which a `to_json()` method exists. The constructor forwards the parameter @a val to that method (to `json_serializer::to_json` method with `U = uncvref_t`, to be exact). @@ -10340,7 +10340,7 @@ class basic_json @return copy of the element at key @a key or @a default_value if @a key is not found - @throw type_error.306 if the JSON value is not an objec; in that cases, + @throw type_error.306 if the JSON value is not an object; in that cases, using `value()` with a key makes no sense. @complexity Logarithmic in the size of the container. @@ -10413,7 +10413,7 @@ class basic_json @return copy of the element at key @a key or @a default_value if @a key is not found - @throw type_error.306 if the JSON value is not an objec; in that cases, + @throw type_error.306 if the JSON value is not an object; in that cases, using `value()` with a key makes no sense. @complexity Logarithmic in the size of the container. diff --git a/external/include/miniz.h b/external/include/miniz.h index 68cd8717d3153..c15a4429bc0c7 100644 --- a/external/include/miniz.h +++ b/external/include/miniz.h @@ -1296,7 +1296,7 @@ mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive * /* An archive must be manually finalized by calling this function for it to be valid. */ mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip); -/* Finalizes a heap archive, returning a poiner to the heap block and its size. */ +/* Finalizes a heap archive, returning a pointer to the heap block and its size. */ /* The heap block will be allocated using the mz_zip_archive's alloc/realloc callbacks. */ mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **ppBuf, size_t *pSize); diff --git a/external/include/stb_image.h b/external/include/stb_image.h index 250fc1e1071e2..f5990202eb546 100644 --- a/external/include/stb_image.h +++ b/external/include/stb_image.h @@ -5705,7 +5705,7 @@ static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req // Else if n is 128, noop. // Endloop - // The RLE-compressed data is preceeded by a 2-byte data count for each row in the data, + // The RLE-compressed data is preceded by a 2-byte data count for each row in the data, // which we're going to just skip. stbi__skip(s, h * channelCount * 2 ); diff --git a/external/include/stb_image_write.h b/external/include/stb_image_write.h index 9d553e0d7d0a6..8f3f001f19940 100644 --- a/external/include/stb_image_write.h +++ b/external/include/stb_image_write.h @@ -910,7 +910,7 @@ static unsigned char stbiw__paeth(int a, int b, int c) return STBIW_UCHAR(c); } -// @OPTIMIZE: provide an option that always forces left-predict or paeth predict +// @OPTIMIZE: provide an option that always forces left-predict or path predict unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len) { int ctype[5] = { -1, 0, 4, 2, 6 }; diff --git a/external/include/stb_truetype.h b/external/include/stb_truetype.h index e1b6d4c6da3f3..7417c94b1454d 100644 --- a/external/include/stb_truetype.h +++ b/external/include/stb_truetype.h @@ -75,7 +75,7 @@ // // USAGE // -// Include this file in whatever places neeed to refer to it. In ONE C/C++ +// Include this file in whatever places need to refer to it. In ONE C/C++ // file, write: // #define STB_TRUETYPE_IMPLEMENTATION // before the #include of this file. This expands out the actual @@ -214,7 +214,7 @@ // Sample code 140 LOC / // Truetype parsing 620 LOC ---- 620 LOC TrueType // Software rasterization 240 LOC \ . -// Curve tesselation 120 LOC \__ 550 LOC Bitmap creation +// Curve tessellation 120 LOC \__ 550 LOC Bitmap creation // Bitmap management 100 LOC / // Baked bitmap interface 70 LOC / // Font name matching & access 150 LOC ---- 150 @@ -647,7 +647,7 @@ STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index); // file will only define one font and it always be at offset 0, so it will // return '0' for index 0, and -1 for all other indices. -// The following structure is defined publically so you can declare one on +// The following structure is defined publicly so you can declare one on // the stack or as a global or etc, but you should treat it as opaque. struct stbtt_fontinfo { @@ -767,7 +767,7 @@ STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, s // returns # of vertices and fills *vertices with the pointer to them // these are expressed in "unscaled" coordinates // -// The shape is a series of countours. Each one starts with +// The shape is a series of contours. Each one starts with // a STBTT_moveto, then consists of a series of mixed // STBTT_lineto and STBTT_curveto segments. A lineto // draws a line from previous endpoint to its x,y; a curveto @@ -2853,7 +2853,7 @@ static void stbtt__sort_edges_ins_sort(stbtt__edge *p, int n) static void stbtt__sort_edges_quicksort(stbtt__edge *p, int n) { - /* threshhold for transitioning to insertion sort */ + /* threshold for transitioning to insertion sort */ while (n > 12) { stbtt__edge t; int c01,c12,c,m,i,j; @@ -2988,7 +2988,7 @@ static void stbtt__add_point(stbtt__point *points, int n, float x, float y) points[n].y = y; } -// tesselate until threshhold p is happy... @TODO warped to compensate for non-linear stretching +// tessellate until threshold p is happy... @TODO warped to compensate for non-linear stretching static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float objspace_flatness_squared, int n) { // midpoint diff --git a/misc/prtags.json b/misc/prtags.json index b108c159eacf6..f7c04b8055e71 100644 --- a/misc/prtags.json +++ b/misc/prtags.json @@ -41,7 +41,7 @@ "ipython" : "IPython and other shells", "cc" : "C source backend", "error" : "Error messages", - "blender" : "Blender intergration", + "blender" : "Blender integration", "export" : "Exporting kernels", "type" : "Type system", "simt" : "SIMT programming", diff --git a/python/taichi/_funcs.py b/python/taichi/_funcs.py index 6fce332466981..d455dfe33d1a1 100644 --- a/python/taichi/_funcs.py +++ b/python/taichi/_funcs.py @@ -594,7 +594,7 @@ def solve(A, b, dt=None): Returns: x (ti.Vector(n, 1)): the solution of Ax=b. """ - assert A.n == A.m, "Only sqaure matrix is supported" + assert A.n == A.m, "Only square matrix is supported" assert A.n >= 2 and A.n <= 3, "Only 2D and 3D matrices are supported" assert A.m == b.n, "Matrix and Vector dimension dismatch" if dt is None: diff --git a/python/taichi/_main.py b/python/taichi/_main.py index 210951aacb626..ddd9446cbf04a 100644 --- a/python/taichi/_main.py +++ b/python/taichi/_main.py @@ -24,7 +24,7 @@ def timer(func): - """Function decorator to benchmark a function runnign time.""" + """Function decorator to benchmark a function running time.""" @wraps(func) def wrapper(*args, **kwargs): start = timeit.default_timer() @@ -37,7 +37,7 @@ def wrapper(*args, **kwargs): def registerableCLI(cls): - """Class decorator to register methodss with @register into a set.""" + """Class decorator to register methods with @register into a set.""" cls.registered_commands = set([]) for name in dir(cls): method = getattr(cls, name) @@ -140,7 +140,7 @@ def support_choice_with_dot_py(choice): return support_choice_with_dot_py @register - def gallery(self, argumets: list = sys.argv[2:]): + def gallery(self, arguments: list = sys.argv[2:]): """Use mouse to select and run taichi examples in an interactive gui.""" # set the spacing parameters in the gallery image slide_bar = 14 diff --git a/python/taichi/_snode/fields_builder.py b/python/taichi/_snode/fields_builder.py index 9b77350140715..82363ba050e9d 100644 --- a/python/taichi/_snode/fields_builder.py +++ b/python/taichi/_snode/fields_builder.py @@ -22,7 +22,7 @@ class FieldsBuilder: fb.dense(ti.ij, 8).place(x) fb.pointer(ti.ij, 8).dense(ti.ij, 4).place(y) - # Afer this line, `x` and `y` are placed. No more fields can be placed + # After this line, `x` and `y` are placed. No more fields can be placed # into `fb`. # # The tree looks like the following: diff --git a/python/taichi/aot/utils.py b/python/taichi/aot/utils.py index e94b648d1ccab..f94ae3e594e69 100644 --- a/python/taichi/aot/utils.py +++ b/python/taichi/aot/utils.py @@ -76,7 +76,7 @@ def produce_injected_args(kernel, symbolic_args=None): if symbolic_mat_m != anno.m or symbolic_mat_n != anno.n: raise RuntimeError( f'Matrix dimension mismatch, expected ({anno.n}, {anno.m}) ' - f'but dispathed shape ({symbolic_mat_n}, {symbolic_mat_m}).' + f'but dispatched shape ({symbolic_mat_n}, {symbolic_mat_m}).' ) injected_args.append(Matrix([0] * anno.n * anno.m, dt=anno.dtype)) else: diff --git a/python/taichi/examples/features/io/export_mesh.py b/python/taichi/examples/features/io/export_mesh.py index f3fbbefe5d887..5181442c5dba0 100644 --- a/python/taichi/examples/features/io/export_mesh.py +++ b/python/taichi/examples/features/io/export_mesh.py @@ -30,11 +30,11 @@ np.array(list(np.arange(0, 3)) * 4) + 4 * np.repeat(np.arange(4), 3), 4) writer.add_faces(indices) -# Add custome vertex channel, the input should include a key, a supported datatype and, the data np.array +# Add custom vertex channel, the input should include a key, a supported datatype and, the data np.array vdata = np.random.rand(20) writer.add_vertex_channel("vdata1", "double", vdata) -# Add custome face channel +# Add custom face channel foo_data = np.zeros(12) writer.add_face_channel("foo_key", "foo_data_type", foo_data) # error! because "foo_data_type" is not a supported datatype. Supported ones are diff --git a/python/taichi/examples/ggui_examples/fem128_ggui.py b/python/taichi/examples/ggui_examples/fem128_ggui.py index 47b102181dcbc..cb62da87d4a3c 100644 --- a/python/taichi/examples/ggui_examples/fem128_ggui.py +++ b/python/taichi/examples/ggui_examples/fem128_ggui.py @@ -150,7 +150,7 @@ def main(): gravity[None] = [0, -1] print( - "[Hint] Use WSAD/arrow keys to control gravity. Use left/right mouse bottons to attract/repel. Press R to reset." + "[Hint] Use WSAD/arrow keys to control gravity. Use left/right mouse buttons to attract/repel. Press R to reset." ) while window.running: for e in window.get_events(ti.ui.PRESS): diff --git a/python/taichi/examples/ggui_examples/mpm128_ggui.py b/python/taichi/examples/ggui_examples/mpm128_ggui.py index 71c34ee38279b..6a5801c1fb27f 100644 --- a/python/taichi/examples/ggui_examples/mpm128_ggui.py +++ b/python/taichi/examples/ggui_examples/mpm128_ggui.py @@ -139,7 +139,7 @@ def render(): def main(): print( - "[Hint] Use WSAD/arrow keys to control gravity. Use left/right mouse bottons to attract/repel. Press R to reset." + "[Hint] Use WSAD/arrow keys to control gravity. Use left/right mouse buttons to attract/repel. Press R to reset." ) res = (512, 512) diff --git a/python/taichi/examples/rendering/cornell_box.py b/python/taichi/examples/rendering/cornell_box.py index b7d2a08aa8a75..81aca7d6849b0 100644 --- a/python/taichi/examples/rendering/cornell_box.py +++ b/python/taichi/examples/rendering/cornell_box.py @@ -37,7 +37,7 @@ light_color = ti.Vector(list(np.array([0.9, 0.85, 0.7]))) light_normal = ti.Vector([0.0, -1.0, 0.0]) -# No absorbtion, integrates over a unit hemisphere +# No absorption, integrates over a unit hemisphere lambertian_brdf = 1.0 / np.pi # diamond! refr_idx = 2.4 diff --git a/python/taichi/examples/simulation/euler.py b/python/taichi/examples/simulation/euler.py index 421ebdd39e5ce..eacbe2db63cd1 100644 --- a/python/taichi/examples/simulation/euler.py +++ b/python/taichi/examples/simulation/euler.py @@ -315,7 +315,7 @@ def thinc(wl, wc, wr, beta): @ti.kernel def compute_F_thinc(): - # reconstruct primitve variables on interior faces of each cell using + # reconstruct primitive variables on interior faces of each cell using # multiple candidate thinc reconstructions for i, j in Q: if is_interior_cell(i, j): diff --git a/python/taichi/examples/simulation/fem128.py b/python/taichi/examples/simulation/fem128.py index f3d37145ee461..75f16405d21da 100644 --- a/python/taichi/examples/simulation/fem128.py +++ b/python/taichi/examples/simulation/fem128.py @@ -111,7 +111,7 @@ def main(): gui = ti.GUI('FEM128') print( - "[Hint] Use WSAD/arrow keys to control gravity. Use left/right mouse bottons to attract/repel. Press R to reset." + "[Hint] Use WSAD/arrow keys to control gravity. Use left/right mouse buttons to attract/repel. Press R to reset." ) while gui.running: for e in gui.get_events(gui.PRESS): diff --git a/python/taichi/examples/simulation/initial_value_problem.py b/python/taichi/examples/simulation/initial_value_problem.py index 058c628ec465e..d0b888c519713 100644 --- a/python/taichi/examples/simulation/initial_value_problem.py +++ b/python/taichi/examples/simulation/initial_value_problem.py @@ -38,9 +38,9 @@ def paint(t: float): def main(): gui = ti.GUI("Vector Field", res=(500, 500)) - begining = time.time_ns() + beginning = time.time_ns() for k in range(1000000): - paint((time.time_ns() - begining) * 0.00000001) + paint((time.time_ns() - beginning) * 0.00000001) dirs_np = dirs.to_numpy() gui.arrows(locations_np, dirs_np, radius=1) gui.show() diff --git a/python/taichi/examples/simulation/mpm128.py b/python/taichi/examples/simulation/mpm128.py index dfa5172010c17..0c2507b237810 100644 --- a/python/taichi/examples/simulation/mpm128.py +++ b/python/taichi/examples/simulation/mpm128.py @@ -123,7 +123,7 @@ def reset(): print( - "[Hint] Use WSAD/arrow keys to control gravity. Use left/right mouse bottons to attract/repel. Press R to reset." + "[Hint] Use WSAD/arrow keys to control gravity. Use left/right mouse buttons to attract/repel. Press R to reset." ) gui = ti.GUI("Taichi MLS-MPM-128", res=512, background_color=0x112F41) reset() diff --git a/python/taichi/lang/_ndrange.py b/python/taichi/lang/_ndrange.py index 979a70ccabbe5..bde0e7aab1f04 100644 --- a/python/taichi/lang/_ndrange.py +++ b/python/taichi/lang/_ndrange.py @@ -63,7 +63,7 @@ def ndrange(*args): range(x1, y1) x range(x2, y2) x ... x range(xn, yn) The k-th argument corresponds to the k-th `range()` factor in the above product, and each - argument must be an integer or a pair of two integers. An integer argument n will be intepreted + argument must be an integer or a pair of two integers. An integer argument n will be interpreted as `range(0, n)`, and a pair of two integers (start, end) will be interpreted as `range(start, end)`. You can loop over these multi-dimensonal indices in different ways, see the examples below. diff --git a/python/taichi/lang/ast/ast_transformer.py b/python/taichi/lang/ast/ast_transformer.py index e289caf261107..78b8764523ed6 100644 --- a/python/taichi/lang/ast/ast_transformer.py +++ b/python/taichi/lang/ast/ast_transformer.py @@ -46,7 +46,7 @@ def build_AnnAssign(ctx, node): @staticmethod def build_assign_annotated(ctx, target, value, is_static_assign, annotation): - """Build an annotated assginment like this: target: annotation = value. + """Build an annotated assignment like this: target: annotation = value. Args: ctx (ast_builder_utils.BuilderContext): The builder context. @@ -129,7 +129,7 @@ def build_assign_unpack(ctx, node_target, values, is_static_assign): @staticmethod def build_assign_basic(ctx, target, value, is_static_assign): - """Build basic assginment like this: target = value. + """Build basic assignment like this: target = value. Args: ctx (ast_builder_utils.BuilderContext): The builder context. diff --git a/python/taichi/lang/impl.py b/python/taichi/lang/impl.py index e1957fbf25902..e959d6e16c4a3 100644 --- a/python/taichi/lang/impl.py +++ b/python/taichi/lang/impl.py @@ -422,7 +422,7 @@ def __getattr__(self, item): # gets delayed. `_root_fb` will only exist in the taichi.lang.impl module, so # writing to it is would result in less for maintenance cost. # -# `_root_fb` will be overriden inside :func:`taichi.lang.init`. +# `_root_fb` will be overridden inside :func:`taichi.lang.init`. _root_fb = _UninitializedRootFieldsBuilder() @@ -614,7 +614,7 @@ def entry2content(_var): return Expr(_var).ptr def list_ti_repr(_var): - yield '[' # distinguishing tuple & list will increase maintainance cost + yield '[' # distinguishing tuple & list will increase maintenance cost for i, v in enumerate(_var): if i: yield ', ' diff --git a/python/taichi/lang/matrix.py b/python/taichi/lang/matrix.py index 42f83fa1f8255..e7b5327341371 100644 --- a/python/taichi/lang/matrix.py +++ b/python/taichi/lang/matrix.py @@ -363,7 +363,7 @@ class Matrix(TaichiOperations): """The matrix class. A matrix is a 2-D rectangular array with scalar entries, it's row-majored, and is - aligned continously. We recommend only use matrix with no more than 32 elements for + aligned continuously. We recommend only use matrix with no more than 32 elements for efficiency considerations. Note: in taichi a matrix is strictly two-dimensional and only stores scalars. @@ -582,7 +582,7 @@ def dynamic_index_stride(self): @taichi_scope def _subscript(self, *indices): if isinstance(self._impl, _PyScopeMatrixImpl): - # This can happpen in these cases: + # This can happen in these cases: # 1. A Python scope matrix is passed into a Taichi kernel as ti.template() # 2. Taichi kernel directlly uses a matrix (global variable) created in the Python scope. return self._impl.subscript_scope_ignored(indices) diff --git a/python/taichi/lang/struct.py b/python/taichi/lang/struct.py index 0d197ef78247e..6ec02abae5bcf 100644 --- a/python/taichi/lang/struct.py +++ b/python/taichi/lang/struct.py @@ -18,7 +18,7 @@ class Struct(TaichiOperations): A struct is a dictionary-like data structure that stores members as (key, value) pairs. Valid data members of a struct can be scalars, - matrices or other dictionary-like stuctures. + matrices or other dictionary-like structures. Args: entries (Dict[str, Union[Dict, Expr, Matrix, Struct]]): \ @@ -378,7 +378,7 @@ def __init__(self, entries): class StructField(Field): """Taichi struct field with SNode implementation. - Instead of directly contraining Expr entries, the StructField object + Instead of directly constraining Expr entries, the StructField object directly hosts members as `Field` instances to support nested structs. Args: @@ -700,7 +700,7 @@ def struct_class(cls): A taichi struct with the annotations as fields and methods from the class attached. """ - # save the annotaion fields for the struct + # save the annotation fields for the struct fields = cls.__annotations__ # get the class methods to be attached to the struct types fields['__struct_methods'] = { diff --git a/python/taichi/math/mathimpl.py b/python/taichi/math/mathimpl.py index d3c3c0234331a..6018ed073ef94 100644 --- a/python/taichi/math/mathimpl.py +++ b/python/taichi/math/mathimpl.py @@ -71,7 +71,7 @@ def uvec4(*args): def _gen_matrix(n, *args): """Supports more matrix construction routines. - 1. Usual contruction (from a 2d list or a single scalar). + 1. Usual construction (from a 2d list or a single scalar). 2. From a 1-D array of n*n elements (glsl style). 3. From a list of n-D vectors (glsl style). """ @@ -80,7 +80,7 @@ def _gen_matrix(n, *args): return ti.Matrix(data, float) if len(args) == n: # initialize with n vectors - # Matrix.rows() will do implict type inference + # Matrix.rows() will do implicit type inference data = [list(x) for x in args] return ti.Matrix(data, float) @@ -578,7 +578,7 @@ def rotate3d(p, axis, ang): @ti.func def eye(n: ti.template()): - """Returns the nxn identiy matrix. + """Returns the nxn identity matrix. Alias for :func:`~taichi.Matrix.identity`. """ diff --git a/python/taichi/profiler/kernel_metrics.py b/python/taichi/profiler/kernel_metrics.py index dd47ad98fcd57..861f28f74ad49 100644 --- a/python/taichi/profiler/kernel_metrics.py +++ b/python/taichi/profiler/kernel_metrics.py @@ -234,7 +234,7 @@ def get_predefined_cupti_metrics(name=''): # Default metrics list default_cupti_metrics = [dram_bytes_sum] -"""The metrics list, each is an instace of the :class:`~taichi.profiler.CuptiMetric`. +"""The metrics list, each is an instance of the :class:`~taichi.profiler.CuptiMetric`. Default to `dram_bytes_sum`. """ diff --git a/python/taichi/profiler/kernel_profiler.py b/python/taichi/profiler/kernel_profiler.py index 6bdf5de97f069..261a8254304c2 100644 --- a/python/taichi/profiler/kernel_profiler.py +++ b/python/taichi/profiler/kernel_profiler.py @@ -422,7 +422,7 @@ def query_kernel_profiler_info(name): >>> for i in range(100): >>> fill() >>> query_result = ti.profiler.query_kernel_profiler_info(fill.__name__) #[2] - >>> print("kernel excuted times =",query_result.counter) + >>> print("kernel executed times =",query_result.counter) >>> print("kernel elapsed time(min_in_ms) =",query_result.min) >>> print("kernel elapsed time(max_in_ms) =",query_result.max) >>> print("kernel elapsed time(avg_in_ms) =",query_result.avg) @@ -510,7 +510,7 @@ def set_kernel_profiler_metrics(metric_list=default_cupti_metrics): >>> for i in x: >>> y[None] += x[i] - >>> # In the case of not pramater, Taichi will print its pre-defined metrics list + >>> # In the case of not parameter, Taichi will print its pre-defined metrics list >>> ti.profiler.get_predefined_cupti_metrics() >>> # get Taichi pre-defined metrics >>> profiling_metrics = ti.profiler.get_predefined_cupti_metrics('shared_access') @@ -558,7 +558,7 @@ def collect_kernel_profiler_metrics(metric_list=default_cupti_metrics): >>> for i in x: >>> y[None] += x[i] - >>> # In the case of not pramater, Taichi will print its pre-defined metrics list + >>> # In the case of not parameter, Taichi will print its pre-defined metrics list >>> ti.profiler.get_predefined_cupti_metrics() >>> # get Taichi pre-defined metrics >>> profiling_metrics = ti.profiler.get_predefined_cupti_metrics('device_utilization') diff --git a/python/taichi/tools/image.py b/python/taichi/tools/image.py index 9fa11b3ca31a3..04692be7e0aba 100644 --- a/python/taichi/tools/image.py +++ b/python/taichi/tools/image.py @@ -78,7 +78,7 @@ def imread(filename, channels=0): Args: filename (str): An image filename to load from. - channels (int, optinal): The channels hint of input image, Default to 0. + channels (int, optional): The channels hint of input image, Default to 0. Returns: np.ndarray : An output image loaded from given filename. diff --git a/python/taichi/types/compound_types.py b/python/taichi/types/compound_types.py index 2c4da9bec6d2d..a55096baad48c 100644 --- a/python/taichi/types/compound_types.py +++ b/python/taichi/types/compound_types.py @@ -53,7 +53,7 @@ def struct(**kwargs): """Creates a struct type with given members. Args: - kwargs (dict): a dictionay contains the names and types of the + kwargs (dict): a dictionary contains the names and types of the struct members. Returns: diff --git a/python/taichi/ui/gui.py b/python/taichi/ui/gui.py index e0f0d86e35876..ddbc99dbb047d 100644 --- a/python/taichi/ui/gui.py +++ b/python/taichi/ui/gui.py @@ -447,7 +447,7 @@ def triangles(self, a, b, c, color=0xFFFFFF): Args: a (numpy.array): The positions of the first points of triangles. b (numpy.array): The positions of the second points of triangles. - c (numpy.array): The positions of the thrid points of triangles. + c (numpy.array): The positions of the third points of triangles. color (Union[int, numpy.array], optional): The color or colors of triangles. Can be either a single color or a list of colors whose shape matches the shape of a & b & c. Default is 0xFFFFFF. diff --git a/python/taichi/ui/ui.py b/python/taichi/ui/ui.py index 3376d2a8196b4..fea324e19070b 100644 --- a/python/taichi/ui/ui.py +++ b/python/taichi/ui/ui.py @@ -13,7 +13,7 @@ def make_camera(): """Return an instance of :class:`~taichi.ui.Camera`. This is the recommended way to create a camera in ggui. - You should also mannually set the camera parameters like `camera.position`, + You should also manually set the camera parameters like `camera.position`, `camera.lookat`, `camera.up`, etc. The default settings may not work for your scene. diff --git a/python/taichi/ui/utils.py b/python/taichi/ui/utils.py index ea317b67701dd..92e76192c8ad8 100644 --- a/python/taichi/ui/utils.py +++ b/python/taichi/ui/utils.py @@ -102,7 +102,7 @@ def check_ggui_availability(): return try: - # Try identifing the reason + # Try identifying the reason import taichi # pylint: disable=import-outside-toplevel wheel_tag = try_get_wheel_tag(taichi) if platform.system( diff --git a/scripts/run_clang_tidy.sh b/scripts/run_clang_tidy.sh index e5bd6813270ad..793d74d020817 100644 --- a/scripts/run_clang_tidy.sh +++ b/scripts/run_clang_tidy.sh @@ -1,6 +1,6 @@ #!/bin/sh -# This script is to be exected from the taichi repo folder i.e. `./scripts/run_clang_tidy.sh` +# This script is to be executed from the taichi repo folder i.e. `./scripts/run_clang_tidy.sh` rm -rf build_clang_tidy mkdir -p build_clang_tidy/ cd build_clang_tidy diff --git a/taichi/analysis/arithmetic_interpretor.h b/taichi/analysis/arithmetic_interpretor.h index 6c56a8ed3db0c..3a40d14051419 100644 --- a/taichi/analysis/arithmetic_interpretor.h +++ b/taichi/analysis/arithmetic_interpretor.h @@ -47,7 +47,7 @@ class ArithmeticInterpretor { } /** - * Tells the interpretor to ignore statement @param s. + * Tells the interpreter to ignore statement @param s. * * This is effective only for statements that are not supported by * ArithmeticInterpretor. @@ -73,7 +73,7 @@ class ArithmeticInterpretor { }; /** - * Defines the region of CHI statments to be evaluated. + * Defines the region of CHI statements to be evaluated. */ struct CodeRegion { // Defines the sequence of CHI statements. diff --git a/taichi/analysis/gather_uniquely_accessed_pointers.cpp b/taichi/analysis/gather_uniquely_accessed_pointers.cpp index 69b4d767a2960..1d2a770120d89 100644 --- a/taichi/analysis/gather_uniquely_accessed_pointers.cpp +++ b/taichi/analysis/gather_uniquely_accessed_pointers.cpp @@ -252,7 +252,7 @@ class UniquelyAccessedSNodeSearcher : public BasicStmtVisitor { /** * We know stmt->base_ptr and the previously recorded pointers * are loop-unique. We need to figure out whether their loop-unique - * indicies are the same while ignoring the others. + * indices are the same while ignoring the others. * e.g. a[i, j, 1] and a[i, j, 2] are both uniquely accessed * a[i, j, 1] and a[j, i, 2] are not uniquely accessed * a[i, j + 1, 1] and a[i, j, 2] are not uniquely accessed diff --git a/taichi/aot/module_builder.h b/taichi/aot/module_builder.h index 02cdb9a83ded4..bc9f10ca714ff 100644 --- a/taichi/aot/module_builder.h +++ b/taichi/aot/module_builder.h @@ -42,7 +42,7 @@ class AotModuleBuilder { protected: /** - * Intended to be overriden by each backend's implementation. + * Intended to be overridden by each backend's implementation. */ virtual void add_per_backend(const std::string &identifier, Kernel *kernel) = 0; diff --git a/taichi/backends/cuda/cuda_driver.cpp b/taichi/backends/cuda/cuda_driver.cpp index e01e1c0fe5bf2..dff941a2fa41f 100644 --- a/taichi/backends/cuda/cuda_driver.cpp +++ b/taichi/backends/cuda/cuda_driver.cpp @@ -22,7 +22,8 @@ bool CUDADriver::detected() { CUDADriver::CUDADriver() { disabled_by_env_ = (get_environ_config("TI_ENABLE_CUDA", 1) == 0); if (disabled_by_env_) { - TI_TRACE("CUDA driver disabled by enviroment variable \"TI_ENABLE_CUDA\"."); + TI_TRACE( + "CUDA driver disabled by environment variable \"TI_ENABLE_CUDA\"."); return; } diff --git a/taichi/backends/cuda/cuda_driver.h b/taichi/backends/cuda/cuda_driver.h index 40e3eff765c63..223db405582c5 100644 --- a/taichi/backends/cuda/cuda_driver.h +++ b/taichi/backends/cuda/cuda_driver.h @@ -6,7 +6,7 @@ #include "taichi/backends/cuda/cuda_types.h" #if (0) -// Turn on to check for comptability +// Turn on to check for compatibility namespace taichi { static_assert(sizeof(CUresult) == sizeof(uint32)); static_assert(sizeof(CUmem_advise) == sizeof(uint32)); diff --git a/taichi/backends/cuda/cuda_types.h b/taichi/backends/cuda/cuda_types.h index 04fd262df9756..2652335b4e7c7 100644 --- a/taichi/backends/cuda/cuda_types.h +++ b/taichi/backends/cuda/cuda_types.h @@ -20,7 +20,7 @@ using CUarray = void *; * Resource types */ typedef enum CUresourcetype_enum { - CU_RESOURCE_TYPE_ARRAY = 0x00, /**< Array resoure */ + CU_RESOURCE_TYPE_ARRAY = 0x00, /**< Array resource */ CU_RESOURCE_TYPE_MIPMAPPED_ARRAY = 0x01, /**< Mipmapped array resource */ CU_RESOURCE_TYPE_LINEAR = 0x02, /**< Linear resource */ CU_RESOURCE_TYPE_PITCH2D = 0x03 /**< Pitch 2D resource */ diff --git a/taichi/backends/cuda/cupti_toolkit.cpp b/taichi/backends/cuda/cupti_toolkit.cpp index 2d2610fc53b09..8beab31e2872e 100644 --- a/taichi/backends/cuda/cupti_toolkit.cpp +++ b/taichi/backends/cuda/cupti_toolkit.cpp @@ -14,7 +14,7 @@ TLANG_NAMESPACE_BEGIN -// Make sure these metrics can be captured in one pass (no kernal replay) +// Make sure these metrics can be captured in one pass (no kernel replay) // Metrics for calculating the kernel elapsed time are collected by default. enum class CuptiMetricsDefault : uint { CUPTI_METRIC_KERNEL_ELAPSED_CLK_NUMS = 0, diff --git a/taichi/backends/vulkan/vulkan_api.h b/taichi/backends/vulkan/vulkan_api.h index cbc7f57280240..8f8b9ccae9167 100644 --- a/taichi/backends/vulkan/vulkan_api.h +++ b/taichi/backends/vulkan/vulkan_api.h @@ -51,7 +51,7 @@ IVkDescriptorSetLayout create_descriptor_set_layout( // VkDescriptorPool struct DeviceObjVkDescriptorPool : public DeviceObj { VkDescriptorPool pool{VK_NULL_HANDLE}; - // Can recyling of this actually be trivial? + // Can recycling of this actually be trivial? // std::unordered_multimap free_list; ~DeviceObjVkDescriptorPool() override; }; diff --git a/taichi/backends/vulkan/vulkan_device.cpp b/taichi/backends/vulkan/vulkan_device.cpp index 42c770102697d..67a085a47a689 100644 --- a/taichi/backends/vulkan/vulkan_device.cpp +++ b/taichi/backends/vulkan/vulkan_device.cpp @@ -2430,7 +2430,7 @@ DeviceAllocation VulkanSurface::get_image_data() { /* if (config_.window_handle) { - // TODO: check if blit is suppoted, and use copy_image if not + // TODO: check if blit is supported, and use copy_image if not cmd_list = stream->new_command_list(); cmd_list->blit_image(screenshot_image_, img_alloc, ImageLayout::transfer_dst, ImageLayout::transfer_src, diff --git a/taichi/codegen/spirv/kernel_utils.h b/taichi/codegen/spirv/kernel_utils.h index f5d02a156b5ed..f042238c32785 100644 --- a/taichi/codegen/spirv/kernel_utils.h +++ b/taichi/codegen/spirv/kernel_utils.h @@ -84,7 +84,7 @@ struct TaskAttributes { OffloadedTaskType task_type; struct RangeForAttributes { - // |begin| has differen meanings depending on |const_begin|: + // |begin| has different meanings depending on |const_begin|: // * true : It is the left boundary of the loop known at compile time. // * false: It is the offset of the begin in the global tmps buffer. // diff --git a/taichi/codegen/spirv/spirv_types.cpp b/taichi/codegen/spirv/spirv_types.cpp index 2f55aaa0bf76b..f8bae9441b061 100644 --- a/taichi/codegen/spirv/spirv_types.cpp +++ b/taichi/codegen/spirv/spirv_types.cpp @@ -98,7 +98,7 @@ size_t SmallVectorType::memory_alignment_size( if (ctx.is() || ctx.is()) { // For STD140 / STD430, small vectors are Power-of-Two aligned - // In C or "Scalar block layout", blocks are aligned to its compoment + // In C or "Scalar block layout", blocks are aligned to its component // alignment if (num_elements_ == 2) { align *= 2; diff --git a/taichi/common/core.h b/taichi/common/core.h index 301116463ecd2..4fea6c4e92a29 100644 --- a/taichi/common/core.h +++ b/taichi/common/core.h @@ -241,10 +241,10 @@ std::vector read(const std::string fn, bool verbose = false); //****************************************************************************** inline std::vector split_string(const std::string &s, - const std::string &seperators) { + const std::string &separators) { std::vector ret; bool is_seperator[256] = {false}; - for (auto &ch : seperators) { + for (auto &ch : separators) { is_seperator[(unsigned int)ch] = true; } int begin = 0; diff --git a/taichi/common/dict.h b/taichi/common/dict.h index 2675765357e1e..c10818059e3e1 100644 --- a/taichi/common/dict.h +++ b/taichi/common/dict.h @@ -347,7 +347,8 @@ inline bool Dict::get(std::string key) const { {"true", true}, {"True", true}, {"t", true}, {"1", true}, {"false", false}, {"False", false}, {"f", false}, {"0", false}, }; - TI_ASSERT_INFO(dict.find(s) != dict.end(), "Unkown identifer for bool: " + s); + TI_ASSERT_INFO(dict.find(s) != dict.end(), + "Unknown identifier for bool: " + s); return dict[s]; } diff --git a/taichi/common/interface.h b/taichi/common/interface.h index 2588124637f42..d9ef18ae8ba04 100644 --- a/taichi/common/interface.h +++ b/taichi/common/interface.h @@ -112,127 +112,127 @@ class InterfaceHolder { } }; -#define TI_INTERFACE(T) \ - extern void *get_implementation_holder_instance_##T(); \ - class TI_IMPLEMENTATION_HOLDER_NAME(T) final \ - : public ImplementationHolderBase { \ - public: \ - TI_IMPLEMENTATION_HOLDER_NAME(T)(const std::string &name) { \ - this->name = name; \ - } \ - using FactoryMethod = std::function()>; \ - using FactoryUniqueMethod = std::function()>; \ - using FactoryUniqueCtorMethod = \ - std::function(const Dict &config)>; \ - using FactoryRawMethod = std::function; \ - using FactoryPlacementMethod = std::function; \ - std::map implementation_factories; \ - std::map \ - implementation_unique_factories; \ - std::map \ - implementation_unique_ctor_factories; \ - std::map implementation_raw_factories; \ - std::map \ - implementation_placement_factories; \ - std::vector get_implementation_names() const override { \ - std::vector names; \ - for (auto &kv : implementation_factories) { \ - names.push_back(kv.first); \ - } \ - return names; \ - } \ - template \ - void insert(const std::string &alias) { \ - implementation_factories.insert( \ - std::make_pair(alias, [&]() { return std::make_shared(); })); \ - implementation_unique_factories.insert( \ - std::make_pair(alias, [&]() { return std::make_unique(); })); \ - implementation_raw_factories.insert( \ - std::make_pair(alias, [&]() { return new G(); })); \ - implementation_placement_factories.insert(std::make_pair( \ - alias, [&](void *place) { return new (place) G(); })); \ - } \ - template \ - void insert_new(const std::string &alias) { \ - /*with ctor*/ \ - implementation_factories.insert( \ - std::make_pair(alias, [&]() { return std::make_shared(); })); \ - implementation_unique_factories.insert( \ - std::make_pair(alias, [&]() { return std::make_unique(); })); \ - implementation_unique_ctor_factories.insert(std::make_pair( \ - alias, \ - [&](const Dict &config) { return std::make_unique(config); })); \ - implementation_raw_factories.insert( \ - std::make_pair(alias, [&]() { return new G(); })); \ - implementation_placement_factories.insert(std::make_pair( \ - alias, [&](void *place) { return new (place) G(); })); \ - } \ - void insert(const std::string &alias, const FactoryMethod &f) { \ - implementation_factories.insert(std::make_pair(alias, f)); \ - } \ - bool has(const std::string &alias) const override { \ - return implementation_factories.find(alias) != \ - implementation_factories.end(); \ - } \ - void remove(const std::string &alias) override { \ - TI_ASSERT_INFO(has(alias), \ - std::string("Implemetation ") + alias + " not found!"); \ - implementation_factories.erase(alias); \ - } \ - void update(const std::string &alias, const FactoryMethod &f) { \ - if (has(alias)) { \ - remove(alias); \ - } \ - insert(alias, f); \ - } \ - template \ - void update(const std::string &alias) { \ - if (has(alias)) { \ - remove(alias); \ - } \ - insert(alias); \ - } \ - std::shared_ptr create(const std::string &alias) { \ - auto factory = implementation_factories.find(alias); \ - TI_ASSERT_INFO( \ - factory != implementation_factories.end(), \ - "Implementation [" + name + "::" + alias + "] not found!"); \ - return (factory->second)(); \ - } \ - std::unique_ptr create_unique(const std::string &alias) { \ - auto factory = implementation_unique_factories.find(alias); \ - TI_ASSERT_INFO( \ - factory != implementation_unique_factories.end(), \ - "Implementation [" + name + "::" + alias + "] not found!"); \ - return (factory->second)(); \ - } \ - std::unique_ptr create_unique_ctor(const std::string &alias, \ - const Dict &config) { \ - auto factory = implementation_unique_ctor_factories.find(alias); \ - TI_ASSERT_INFO( \ - factory != implementation_unique_ctor_factories.end(), \ - "Implementation [" + name + "::" + alias + "] not found!"); \ - return (factory->second)(config); \ - } \ - T *create_raw(const std::string &alias) { \ - auto factory = implementation_raw_factories.find(alias); \ - TI_ASSERT_INFO( \ - factory != implementation_raw_factories.end(), \ - "Implementation [" + name + "::" + alias + "] not found!"); \ - return (factory->second)(); \ - } \ - T *create_placement(const std::string &alias, void *place) { \ - auto factory = implementation_placement_factories.find(alias); \ - TI_ASSERT_INFO( \ - factory != implementation_placement_factories.end(), \ - "Implementation [" + name + "::" + alias + "] not found!"); \ - return (factory->second)(place); \ - } \ - static TI_IMPLEMENTATION_HOLDER_NAME(T) * get_instance() { \ - return static_cast( \ - get_implementation_holder_instance_##T()); \ - } \ - }; \ +#define TI_INTERFACE(T) \ + extern void *get_implementation_holder_instance_##T(); \ + class TI_IMPLEMENTATION_HOLDER_NAME(T) final \ + : public ImplementationHolderBase { \ + public: \ + TI_IMPLEMENTATION_HOLDER_NAME(T)(const std::string &name) { \ + this->name = name; \ + } \ + using FactoryMethod = std::function()>; \ + using FactoryUniqueMethod = std::function()>; \ + using FactoryUniqueCtorMethod = \ + std::function(const Dict &config)>; \ + using FactoryRawMethod = std::function; \ + using FactoryPlacementMethod = std::function; \ + std::map implementation_factories; \ + std::map \ + implementation_unique_factories; \ + std::map \ + implementation_unique_ctor_factories; \ + std::map implementation_raw_factories; \ + std::map \ + implementation_placement_factories; \ + std::vector get_implementation_names() const override { \ + std::vector names; \ + for (auto &kv : implementation_factories) { \ + names.push_back(kv.first); \ + } \ + return names; \ + } \ + template \ + void insert(const std::string &alias) { \ + implementation_factories.insert( \ + std::make_pair(alias, [&]() { return std::make_shared(); })); \ + implementation_unique_factories.insert( \ + std::make_pair(alias, [&]() { return std::make_unique(); })); \ + implementation_raw_factories.insert( \ + std::make_pair(alias, [&]() { return new G(); })); \ + implementation_placement_factories.insert(std::make_pair( \ + alias, [&](void *place) { return new (place) G(); })); \ + } \ + template \ + void insert_new(const std::string &alias) { \ + /*with ctor*/ \ + implementation_factories.insert( \ + std::make_pair(alias, [&]() { return std::make_shared(); })); \ + implementation_unique_factories.insert( \ + std::make_pair(alias, [&]() { return std::make_unique(); })); \ + implementation_unique_ctor_factories.insert(std::make_pair( \ + alias, \ + [&](const Dict &config) { return std::make_unique(config); })); \ + implementation_raw_factories.insert( \ + std::make_pair(alias, [&]() { return new G(); })); \ + implementation_placement_factories.insert(std::make_pair( \ + alias, [&](void *place) { return new (place) G(); })); \ + } \ + void insert(const std::string &alias, const FactoryMethod &f) { \ + implementation_factories.insert(std::make_pair(alias, f)); \ + } \ + bool has(const std::string &alias) const override { \ + return implementation_factories.find(alias) != \ + implementation_factories.end(); \ + } \ + void remove(const std::string &alias) override { \ + TI_ASSERT_INFO(has(alias), \ + std::string("Implementation ") + alias + " not found!"); \ + implementation_factories.erase(alias); \ + } \ + void update(const std::string &alias, const FactoryMethod &f) { \ + if (has(alias)) { \ + remove(alias); \ + } \ + insert(alias, f); \ + } \ + template \ + void update(const std::string &alias) { \ + if (has(alias)) { \ + remove(alias); \ + } \ + insert(alias); \ + } \ + std::shared_ptr create(const std::string &alias) { \ + auto factory = implementation_factories.find(alias); \ + TI_ASSERT_INFO( \ + factory != implementation_factories.end(), \ + "Implementation [" + name + "::" + alias + "] not found!"); \ + return (factory->second)(); \ + } \ + std::unique_ptr create_unique(const std::string &alias) { \ + auto factory = implementation_unique_factories.find(alias); \ + TI_ASSERT_INFO( \ + factory != implementation_unique_factories.end(), \ + "Implementation [" + name + "::" + alias + "] not found!"); \ + return (factory->second)(); \ + } \ + std::unique_ptr create_unique_ctor(const std::string &alias, \ + const Dict &config) { \ + auto factory = implementation_unique_ctor_factories.find(alias); \ + TI_ASSERT_INFO( \ + factory != implementation_unique_ctor_factories.end(), \ + "Implementation [" + name + "::" + alias + "] not found!"); \ + return (factory->second)(config); \ + } \ + T *create_raw(const std::string &alias) { \ + auto factory = implementation_raw_factories.find(alias); \ + TI_ASSERT_INFO( \ + factory != implementation_raw_factories.end(), \ + "Implementation [" + name + "::" + alias + "] not found!"); \ + return (factory->second)(); \ + } \ + T *create_placement(const std::string &alias, void *place) { \ + auto factory = implementation_placement_factories.find(alias); \ + TI_ASSERT_INFO( \ + factory != implementation_placement_factories.end(), \ + "Implementation [" + name + "::" + alias + "] not found!"); \ + return (factory->second)(place); \ + } \ + static TI_IMPLEMENTATION_HOLDER_NAME(T) * get_instance() { \ + return static_cast( \ + get_implementation_holder_instance_##T()); \ + } \ + }; \ extern TI_IMPLEMENTATION_HOLDER_NAME(T) * TI_IMPLEMENTATION_HOLDER_PTR(T); #define TI_INTERFACE_DEF(class_name, base_alias) \ diff --git a/taichi/common/serialization.h b/taichi/common/serialization.h index 3896958fb7f3f..eefb4d7f5c73a 100644 --- a/taichi/common/serialization.h +++ b/taichi/common/serialization.h @@ -311,7 +311,7 @@ class BinarySerializer : public Serializer { std::size_t n = 0; head = 0; if (preserved_ != 0) { - TI_TRACE("perserved = {}", preserved_); + TI_TRACE("preserved = {}", preserved_); // Preserved mode this->preserved = preserved_; assert(c_data != nullptr); diff --git a/taichi/gui/android.cpp b/taichi/gui/android.cpp index 60a5e62a49ff1..9ebdc490e3d97 100644 --- a/taichi/gui/android.cpp +++ b/taichi/gui/android.cpp @@ -1,6 +1,6 @@ #include "taichi/gui/gui.h" -// GGUI is not suppored on Android as the window management is handled by the +// GGUI is not supported on Android as the window management is handled by the // framework directly. It also provides a Canvas through Skia library that users // can leverage for rendering of 2D elements (circle, rectangle, ...) #if defined(TI_GUI_ANDROID) diff --git a/taichi/ir/analysis.h b/taichi/ir/analysis.h index ac536ac3c6bd9..4bc28ada9d332 100644 --- a/taichi/ir/analysis.h +++ b/taichi/ir/analysis.h @@ -206,7 +206,7 @@ DiffRange value_diff_loop_index(Stmt *stmt, Stmt *loop, int index_id); * Result of the value_diff_ptr_index pass. */ struct DiffPtrResult { - // Whether the difference of the checkd statements is certain. + // Whether the difference of the checked statements is certain. bool is_diff_certain{false}; // The difference of the value of two statements (i.e. val1 - val2). This is // meaningful only when |is_diff_certain| is true. diff --git a/taichi/ir/expression_ops.h b/taichi/ir/expression_ops.h index dd18413c8867f..c939a520ac972 100644 --- a/taichi/ir/expression_ops.h +++ b/taichi/ir/expression_ops.h @@ -1,4 +1,4 @@ -// Arithmatic operations +// Arithmetic operations #if defined(TI_EXPRESSION_IMPLEMENTATION) diff --git a/taichi/ir/frontend_ir.cpp b/taichi/ir/frontend_ir.cpp index 9685b04040dcb..884cb5eaaea13 100644 --- a/taichi/ir/frontend_ir.cpp +++ b/taichi/ir/frontend_ir.cpp @@ -212,7 +212,7 @@ void BinaryOpExpression::type_check(CompileConfig *config) { } // Some backends such as vulkan doesn't support fp64 - // Try not promoting to fp64 unless neccessary + // Try not promoting to fp64 unless necessary if (type == BinaryOpType::atan2) { if (lhs_type == PrimitiveType::f64 || rhs_type == PrimitiveType::f64) { ret_type = PrimitiveType::f64; diff --git a/taichi/math/array_2d.h b/taichi/math/array_2d.h index 4a995f2b42b10..04633581a6fb3 100644 --- a/taichi/math/array_2d.h +++ b/taichi/math/array_2d.h @@ -209,7 +209,7 @@ class ArrayND<2, T> { typedef typename std::vector::iterator iterator; int size; Vector2i res; - Vector2 storage_offset = Vector2(0.5f, 0.5f); // defualt : center storage + Vector2 storage_offset = Vector2(0.5f, 0.5f); // default : center storage public: std::vector data; template diff --git a/taichi/math/linalg.h b/taichi/math/linalg.h index 83e87612b29e4..a6c28d83eb859 100644 --- a/taichi/math/linalg.h +++ b/taichi/math/linalg.h @@ -138,7 +138,7 @@ struct VectorND : public VectorNDBase { this->d[i] = f; } - // Function intialization + // Function initialization template < typename F, std::enable_if_t>::value, @@ -679,7 +679,7 @@ struct MatrixND { this->d[3] = v3; } - // Function intialization + // Function initialization template < typename F, std::enable_if_t retain_and_wrap_as_nsobj_unique_ptr(O *nsobj) { // we want to *own* a reference to it, we must call [retain] to increment the // reference counting. // - // In pratice, we find that each pthread (non main-thread) creates its own + // In practice, we find that each pthread (non main-thread) creates its own // autoreleasepool. Without retaining the object, it has caused double-free // on thread exit: // 1. nsobj_unique_ptr calls [release] in its destructor. diff --git a/taichi/program/kernel.h b/taichi/program/kernel.h index edde1482446c4..549563d5df66a 100644 --- a/taichi/program/kernel.h +++ b/taichi/program/kernel.h @@ -148,14 +148,14 @@ class TI_DLL_EXPORT Kernel : public Callable { // True if |ir| is a frontend AST. False if it's already offloaded to CHI IR. bool ir_is_ast_{false}; - // The closure that, if invoked, lauches the backend kernel (shader) + // The closure that, if invoked, launches the backend kernel (shader) FunctionType compiled_{nullptr}; // TODO[#5114]: It's kinda redundant to keep both compiled_ (used for JIT // execution) as well as compiled_aot_kernel_. In fact we'd better unify // everything around compiled_aot_kernel and rename it. std::unique_ptr compiled_aot_kernel_{nullptr}; // A flag to record whether |ir| has been fully lowered. - // lower inital AST all the way down to a bunch of + // lower initial AST all the way down to a bunch of // OffloadedStmt for async execution bool lowered_{false}; std::atomic task_counter_{0}; diff --git a/taichi/program/ndarray.cpp b/taichi/program/ndarray.cpp index 41a38957361f4..448f1937dd8aa 100644 --- a/taichi/program/ndarray.cpp +++ b/taichi/program/ndarray.cpp @@ -65,7 +65,7 @@ Ndarray::Ndarray(DeviceAllocation &devalloc, std::end(element_shape), 1, std::multiplies<>())) { - // When element_shape is specfied but layout is not, default layout is AOS. + // When element_shape is specified but layout is not, default layout is AOS. if (!element_shape.empty() && layout == ExternalArrayLayout::kNull) { layout = ExternalArrayLayout::kAOS; } diff --git a/taichi/program/program.cpp b/taichi/program/program.cpp index 51d85bff91476..7382aa0d5e721 100644 --- a/taichi/program/program.cpp +++ b/taichi/program/program.cpp @@ -460,7 +460,7 @@ void Program::finalize() { synchronize(); if (async_engine) async_engine = nullptr; // Finalize the async engine threads before - // anything else gets destoried. + // anything else gets destroyed. TI_TRACE("Program finalizing..."); if (config.print_benchmark_stat) { diff --git a/taichi/python/export_lang.cpp b/taichi/python/export_lang.cpp index 339e11dd59f22..69f26a6b16f68 100644 --- a/taichi/python/export_lang.cpp +++ b/taichi/python/export_lang.cpp @@ -707,7 +707,7 @@ void export_lang(py::module &m) { // The reason that there are both get_raw_address() and // get_underlying_ptr_address() is that Expr itself is mostly wrapper // around its underlying |expr| (of type Expression). Expr |e| can be - // temporary, while the underlying |expr| is mostly persistant. + // temporary, while the underlying |expr| is mostly persistent. // // Same get_raw_address() implies that get_underlying_ptr_address() are // also the same. The reverse is not true. diff --git a/taichi/runtime/gfx/runtime.cpp b/taichi/runtime/gfx/runtime.cpp index 8201482e61f1b..4924b25249b5e 100644 --- a/taichi/runtime/gfx/runtime.cpp +++ b/taichi/runtime/gfx/runtime.cpp @@ -74,7 +74,7 @@ class HostDeviceContextBlitter { device_->unmap(buffer); } } - // Substitue in the device address if supported + // Substitute in the device address if supported if ((host_ctx_->device_allocation_type[i] == RuntimeContext::DevAllocType::kNone || host_ctx_->device_allocation_type[i] == @@ -274,7 +274,7 @@ CompiledTaichiKernel::CompiledTaichiKernel(const Params &ti_params) input_buffers_[BufferType::ListGen] = ti_params.listgen_buffer; // Compiled_structs can be empty if loading a kernel from an AOT module as - // the SNode are not re-compiled/structured. In thise case, we assume a + // the SNode are not re-compiled/structured. In this case, we assume a // single root buffer size configured from the AOT module. for (int root = 0; root < ti_params.num_snode_trees; ++root) { BufferInfo buffer = {BufferType::Root, root}; diff --git a/taichi/runtime/llvm/llvm_context.h b/taichi/runtime/llvm/llvm_context.h index 3f9dc3953893e..08cd8daa2d96c 100644 --- a/taichi/runtime/llvm/llvm_context.h +++ b/taichi/runtime/llvm/llvm_context.h @@ -49,7 +49,7 @@ class TaichiLLVMContext { /** * Initializes TaichiLLVMContext#runtime_jit_module. * - * Unfortuantely, this cannot be placed inside the constructor. When adding an + * Unfortunately, this cannot be placed inside the constructor. When adding an * llvm::Module, the JITSessionCPU implementation eventually calls back to * this object, so it must be fully constructed by then. */ @@ -65,7 +65,7 @@ class TaichiLLVMContext { /** * Updates the LLVM module of the JIT compiled SNode structs. * - * @param module Module containg the JIT compiled SNode structs. + * @param module Module containing the JIT compiled SNode structs. */ void set_struct_module(const std::unique_ptr &module); diff --git a/taichi/runtime/llvm/llvm_runtime_executor.cpp b/taichi/runtime/llvm/llvm_runtime_executor.cpp index f442cf161440f..800d69f47cab9 100644 --- a/taichi/runtime/llvm/llvm_runtime_executor.cpp +++ b/taichi/runtime/llvm/llvm_runtime_executor.cpp @@ -220,7 +220,7 @@ void LlvmRuntimeExecutor::check_runtime_error(uint64 *result_buffer) { // Here we fetch the error_message_template char by char. // This is not efficient, but fortunately we only need to do this when an // assertion fails. Note that we may not have unified memory here, so using - // "fetch_result" that works across device/host memroy is necessary. + // "fetch_result" that works across device/host memory is necessary. for (int i = 0;; i++) { runtime_jit_module->call("runtime_retrieve_error_message", llvm_runtime_, i); diff --git a/taichi/runtime/llvm/runtime_module/internal_functions.h b/taichi/runtime/llvm/runtime_module/internal_functions.h index 591ccddc64bcf..89c23fd998877 100644 --- a/taichi/runtime/llvm/runtime_module/internal_functions.h +++ b/taichi/runtime/llvm/runtime_module/internal_functions.h @@ -165,7 +165,7 @@ i32 test_active_mask(RuntimeContext *context) { auto remaining = active_mask; while (remaining) { auto leader = cttz_i32(remaining); - taichi_printf(rt, "currnet leader %d bid %d tid %d\n", leader, block_idx(), + taichi_printf(rt, "current leader %d bid %d tid %d\n", leader, block_idx(), thread_idx()); warp_barrier(active_mask); remaining &= ~(1u << leader); diff --git a/taichi/runtime/metal/kernel_manager.cpp b/taichi/runtime/metal/kernel_manager.cpp index 94397babf3ac2..e2b9ae604e507 100644 --- a/taichi/runtime/metal/kernel_manager.cpp +++ b/taichi/runtime/metal/kernel_manager.cpp @@ -897,7 +897,7 @@ class KernelManager::Impl { // Initialize the memory allocator dev_mem_alloc_mirror_ = reinterpret_cast(addr); - // Make sure the retured memory address is always greater than 1. + // Make sure the returned memory address is always greater than 1. dev_mem_alloc_mirror_->next = shaders::MemoryAllocator::kInitOffset; TI_DEBUG("Memory allocator, begin={} next={}", (addr - addr_begin), dev_mem_alloc_mirror_->next); @@ -1169,7 +1169,7 @@ class KernelManager::Impl { } else if (dt == MsgType::Str) { py_cout << print_strtable_.get(x); } else { - TI_ERROR("Unexecpted data type={}", dt); + TI_ERROR("Unexpected data type={}", dt); } } buf += shaders::mtl_compute_print_msg_bytes(num_entries); diff --git a/taichi/runtime/metal/kernel_utils.h b/taichi/runtime/metal/kernel_utils.h index 64ad790ed4e22..db565bf2bd84e 100644 --- a/taichi/runtime/metal/kernel_utils.h +++ b/taichi/runtime/metal/kernel_utils.h @@ -124,7 +124,7 @@ struct KernelAttributes { OffloadedTaskType task_type; struct RangeForAttributes { - // |begin| has differen meanings depending on |const_begin|: + // |begin| has different meanings depending on |const_begin|: // * true : It is the left boundary of the loop known at compile time. // * false: It is the offset of the begin in the global tmps buffer. // diff --git a/taichi/system/traceback.cpp b/taichi/system/traceback.cpp index e2e0e4d189f86..7325d4dbc2e21 100644 --- a/taichi/system/traceback.cpp +++ b/taichi/system/traceback.cpp @@ -205,7 +205,7 @@ void print_traceback() { // TODO: print line number instead of offset // (https://stackoverflow.com/questions/8278691/how-to-fix-backtrace-line-number-error-in-c) - // record stack trace upto 128 frames + // record stack trace up to 128 frames void *callstack[128] = {}; // collect stack frames int frames = backtrace((void **)callstack, 128); diff --git a/taichi/transforms/auto_diff.cpp b/taichi/transforms/auto_diff.cpp index 99766cdb6631d..0d58755fa8966 100644 --- a/taichi/transforms/auto_diff.cpp +++ b/taichi/transforms/auto_diff.cpp @@ -736,7 +736,7 @@ class MakeAdjoint : public ADTransform { // GlobalLoadStmt is not inside a range-for // Code sample: // a and b require grad - // Case 1 (GlobalLoadStmt is ouside the for-loop, compute 5 times and + // Case 1 (GlobalLoadStmt is outside the for-loop, compute 5 times and // accumulate once, alloca history value is needed): // for i in range(5): // p = a[i] diff --git a/taichi/transforms/type_check.cpp b/taichi/transforms/type_check.cpp index 10132bafd3d40..b19b7d044a21c 100644 --- a/taichi/transforms/type_check.cpp +++ b/taichi/transforms/type_check.cpp @@ -301,7 +301,7 @@ class TypeCheck : public IRVisitor { } // Some backends such as vulkan doesn't support fp64 - // Always promote to fp32 unless neccessary + // Always promote to fp32 unless necessary if (stmt->op_type == BinaryOpType::atan2) { if (stmt->rhs->ret_type == PrimitiveType::f64 || stmt->lhs->ret_type == PrimitiveType::f64) { diff --git a/taichi/ui/backends/vulkan/gui.cpp b/taichi/ui/backends/vulkan/gui.cpp index 72fdf848e0953..d169110b77f9b 100644 --- a/taichi/ui/backends/vulkan/gui.cpp +++ b/taichi/ui/backends/vulkan/gui.cpp @@ -38,7 +38,7 @@ Gui::Gui(AppContext *app_context, SwapChain *swap_chain, TaichiWindow *window) { void Gui::init_render_resources(VkRenderPass render_pass) { ImGui_ImplVulkan_LoadFunctions( - load_vk_function_for_gui); // this is becaus we're using volk. + load_vk_function_for_gui); // this is because we're using volk. auto &device = app_context_->device(); diff --git a/tests/cpp/codegen/refine_coordinates_test.cpp b/tests/cpp/codegen/refine_coordinates_test.cpp index 12f550297d306..bcfd834f8ac71 100644 --- a/tests/cpp/codegen/refine_coordinates_test.cpp +++ b/tests/cpp/codegen/refine_coordinates_test.cpp @@ -24,7 +24,7 @@ constexpr char kFuncName[] = "run_refine_coords"; class InvokeRefineCoordinatesBuilder : public LLVMModuleBuilder { public: - // 1st arg: Value of the first parent physical coordiantes + // 1st arg: Value of the first parent physical coordinates // 2nd arg: The child index // ret : Value of the first child physical coordinates using FuncType = int (*)(int, int); diff --git a/tests/python/test_customized_grad.py b/tests/python/test_customized_grad.py index e12179b93a524..fbd7cc7eb1ac6 100644 --- a/tests/python/test_customized_grad.py +++ b/tests/python/test_customized_grad.py @@ -213,7 +213,7 @@ def func(mul: ti.f32): for i in range(n): ti.atomic_add(total[None], x[i] * mul) - def foward(mul): + def forward(mul): func(mul) func(mul) diff --git a/tests/python/test_ggui.py b/tests/python/test_ggui.py index 9cd9f1a6cd205..a2603d0162658 100644 --- a/tests/python/test_ggui.py +++ b/tests/python/test_ggui.py @@ -30,7 +30,7 @@ def write_temp_image(window): pass -def verify_image(window, image_name, tolerence=0.1): +def verify_image(window, image_name, tolerance=0.1): if REGENERATE_GROUNDTRUTH_IMAGES: ground_truth_name = f"tests/python/expected/{image_name}.png" window.write_image(ground_truth_name) @@ -46,7 +46,7 @@ def verify_image(window, image_name, tolerence=0.1): assert ground_truth_np.shape[i] == actual_np.shape[i] diff = ground_truth_np - actual_np mse = np.mean(diff * diff) - assert mse <= tolerence # the pixel values are 0~255 + assert mse <= tolerance # the pixel values are 0~255 os.remove(actual_name) @@ -144,7 +144,7 @@ def render(): write_temp_image(window) render() if (platform.system() == 'Darwin'): - # FIXME: Use lower tolerence when macOS ggui supports wide lines + # FIXME: Use lower tolerance when macOS ggui supports wide lines verify_image(window, 'test_geometry_2d', 1.0) else: verify_image(window, 'test_geometry_2d')