gstaichi 0.1.23.dev0__cp310-cp310-win_amd64.whl → 1.0.1__cp310-cp310-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gstaichi/CHANGELOG.md +6 -0
- gstaichi/__init__.py +40 -0
- {taichi → gstaichi}/_funcs.py +8 -8
- {taichi → gstaichi}/_kernels.py +19 -19
- gstaichi/_lib/__init__.py +3 -0
- taichi/_lib/core/taichi_python.cp310-win_amd64.pyd → gstaichi/_lib/core/gstaichi_python.cp310-win_amd64.pyd +0 -0
- taichi/_lib/core/taichi_python.pyi → gstaichi/_lib/core/gstaichi_python.pyi +382 -522
- {taichi → gstaichi}/_lib/runtime/runtime_cuda.bc +0 -0
- {taichi → gstaichi}/_lib/runtime/runtime_x64.bc +0 -0
- {taichi → gstaichi}/_lib/utils.py +15 -15
- {taichi → gstaichi}/_logging.py +1 -1
- gstaichi/_snode/__init__.py +5 -0
- {taichi → gstaichi}/_snode/fields_builder.py +27 -29
- {taichi → gstaichi}/_snode/snode_tree.py +5 -5
- gstaichi/_test_tools/__init__.py +0 -0
- gstaichi/_test_tools/load_kernel_string.py +30 -0
- gstaichi/_version.py +1 -0
- {taichi → gstaichi}/_version_check.py +8 -5
- gstaichi/ad/__init__.py +3 -0
- {taichi → gstaichi}/ad/_ad.py +26 -26
- {taichi → gstaichi}/algorithms/_algorithms.py +7 -7
- {taichi → gstaichi}/examples/minimal.py +1 -1
- {taichi → gstaichi}/experimental.py +1 -1
- gstaichi/lang/__init__.py +50 -0
- {taichi → gstaichi}/lang/_ndarray.py +30 -26
- {taichi → gstaichi}/lang/_ndrange.py +8 -8
- gstaichi/lang/_template_mapper.py +199 -0
- {taichi → gstaichi}/lang/_texture.py +19 -19
- {taichi → gstaichi}/lang/_wrap_inspect.py +7 -7
- {taichi → gstaichi}/lang/any_array.py +13 -13
- {taichi → gstaichi}/lang/argpack.py +29 -29
- gstaichi/lang/ast/__init__.py +5 -0
- {taichi → gstaichi}/lang/ast/ast_transformer.py +94 -582
- {taichi → gstaichi}/lang/ast/ast_transformer_utils.py +54 -41
- gstaichi/lang/ast/ast_transformers/__init__.py +0 -0
- gstaichi/lang/ast/ast_transformers/call_transformer.py +267 -0
- gstaichi/lang/ast/ast_transformers/function_def_transformer.py +320 -0
- {taichi → gstaichi}/lang/ast/checkers.py +5 -5
- gstaichi/lang/ast/transform.py +9 -0
- {taichi → gstaichi}/lang/common_ops.py +12 -12
- gstaichi/lang/exception.py +80 -0
- {taichi → gstaichi}/lang/expr.py +22 -22
- {taichi → gstaichi}/lang/field.py +29 -27
- {taichi → gstaichi}/lang/impl.py +116 -121
- {taichi → gstaichi}/lang/kernel_arguments.py +16 -16
- {taichi → gstaichi}/lang/kernel_impl.py +330 -363
- {taichi → gstaichi}/lang/matrix.py +119 -115
- {taichi → gstaichi}/lang/matrix_ops.py +6 -6
- {taichi → gstaichi}/lang/matrix_ops_utils.py +4 -4
- {taichi → gstaichi}/lang/mesh.py +22 -22
- {taichi → gstaichi}/lang/misc.py +39 -68
- {taichi → gstaichi}/lang/ops.py +146 -141
- {taichi → gstaichi}/lang/runtime_ops.py +2 -2
- {taichi → gstaichi}/lang/shell.py +3 -3
- {taichi → gstaichi}/lang/simt/__init__.py +1 -1
- {taichi → gstaichi}/lang/simt/block.py +7 -7
- {taichi → gstaichi}/lang/simt/grid.py +1 -1
- {taichi → gstaichi}/lang/simt/subgroup.py +1 -1
- {taichi → gstaichi}/lang/simt/warp.py +1 -1
- {taichi → gstaichi}/lang/snode.py +46 -44
- {taichi → gstaichi}/lang/source_builder.py +13 -13
- {taichi → gstaichi}/lang/struct.py +33 -33
- {taichi → gstaichi}/lang/util.py +24 -24
- gstaichi/linalg/__init__.py +8 -0
- {taichi → gstaichi}/linalg/matrixfree_cg.py +14 -14
- {taichi → gstaichi}/linalg/sparse_cg.py +10 -10
- {taichi → gstaichi}/linalg/sparse_matrix.py +23 -23
- {taichi → gstaichi}/linalg/sparse_solver.py +21 -21
- {taichi → gstaichi}/math/__init__.py +1 -1
- {taichi → gstaichi}/math/_complex.py +21 -20
- {taichi → gstaichi}/math/mathimpl.py +56 -56
- gstaichi/profiler/__init__.py +6 -0
- {taichi → gstaichi}/profiler/kernel_metrics.py +11 -11
- {taichi → gstaichi}/profiler/kernel_profiler.py +30 -36
- {taichi → gstaichi}/profiler/memory_profiler.py +1 -1
- {taichi → gstaichi}/profiler/scoped_profiler.py +2 -2
- {taichi → gstaichi}/sparse/_sparse_grid.py +7 -7
- {taichi → gstaichi}/tools/__init__.py +4 -4
- {taichi → gstaichi}/tools/diagnose.py +10 -17
- gstaichi/types/__init__.py +19 -0
- {taichi → gstaichi}/types/annotations.py +1 -1
- {taichi → gstaichi}/types/compound_types.py +8 -8
- {taichi → gstaichi}/types/enums.py +1 -1
- {taichi → gstaichi}/types/ndarray_type.py +7 -7
- {taichi → gstaichi}/types/primitive_types.py +17 -14
- {taichi → gstaichi}/types/quant.py +9 -9
- {taichi → gstaichi}/types/texture_type.py +5 -5
- {taichi → gstaichi}/types/utils.py +1 -1
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/bin/SPIRV-Tools-shared.dll +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/lib/SPIRV-Tools-diff.lib +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/lib/SPIRV-Tools-link.lib +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/lib/SPIRV-Tools-lint.lib +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/lib/SPIRV-Tools-opt.lib +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/lib/SPIRV-Tools-reduce.lib +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/lib/SPIRV-Tools-shared.lib +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/lib/SPIRV-Tools.lib +0 -0
- {gstaichi-0.1.23.dev0.dist-info → gstaichi-1.0.1.dist-info}/METADATA +13 -16
- gstaichi-1.0.1.dist-info/RECORD +135 -0
- gstaichi-1.0.1.dist-info/top_level.txt +1 -0
- gstaichi-0.1.23.dev0.data/data/include/GLFW/glfw3.h +0 -6389
- gstaichi-0.1.23.dev0.data/data/include/GLFW/glfw3native.h +0 -594
- gstaichi-0.1.23.dev0.data/data/lib/cmake/glfw3/glfw3Config.cmake +0 -3
- gstaichi-0.1.23.dev0.data/data/lib/cmake/glfw3/glfw3ConfigVersion.cmake +0 -65
- gstaichi-0.1.23.dev0.data/data/lib/cmake/glfw3/glfw3Targets-release.cmake +0 -19
- gstaichi-0.1.23.dev0.data/data/lib/cmake/glfw3/glfw3Targets.cmake +0 -107
- gstaichi-0.1.23.dev0.data/data/lib/glfw3.lib +0 -0
- gstaichi-0.1.23.dev0.dist-info/RECORD +0 -198
- gstaichi-0.1.23.dev0.dist-info/entry_points.txt +0 -2
- gstaichi-0.1.23.dev0.dist-info/top_level.txt +0 -1
- taichi/CHANGELOG.md +0 -20
- taichi/__init__.py +0 -44
- taichi/__main__.py +0 -5
- taichi/_lib/__init__.py +0 -3
- taichi/_lib/c_api/bin/taichi_c_api.dll +0 -0
- taichi/_lib/c_api/include/taichi/cpp/taichi.hpp +0 -1401
- taichi/_lib/c_api/include/taichi/taichi.h +0 -29
- taichi/_lib/c_api/include/taichi/taichi_core.h +0 -1111
- taichi/_lib/c_api/include/taichi/taichi_cpu.h +0 -29
- taichi/_lib/c_api/include/taichi/taichi_cuda.h +0 -36
- taichi/_lib/c_api/include/taichi/taichi_platform.h +0 -55
- taichi/_lib/c_api/include/taichi/taichi_unity.h +0 -64
- taichi/_lib/c_api/include/taichi/taichi_vulkan.h +0 -151
- taichi/_lib/c_api/lib/taichi_c_api.lib +0 -0
- taichi/_lib/c_api/runtime/runtime_cuda.bc +0 -0
- taichi/_lib/c_api/runtime/runtime_x64.bc +0 -0
- taichi/_lib/c_api/taichi/lib/cmake/taichi/TaichiConfig.cmake +0 -29
- taichi/_lib/c_api/taichi/lib/cmake/taichi/TaichiConfigVersion.cmake +0 -65
- taichi/_lib/c_api/taichi/lib/cmake/taichi/TaichiTargets.cmake +0 -121
- taichi/_lib/runtime/slim_libdevice.10.bc +0 -0
- taichi/_main.py +0 -552
- taichi/_snode/__init__.py +0 -5
- taichi/_ti_module/__init__.py +0 -3
- taichi/_ti_module/cppgen.py +0 -309
- taichi/_ti_module/module.py +0 -145
- taichi/_version.py +0 -1
- taichi/ad/__init__.py +0 -3
- taichi/aot/__init__.py +0 -12
- taichi/aot/_export.py +0 -28
- taichi/aot/conventions/__init__.py +0 -3
- taichi/aot/conventions/gfxruntime140/__init__.py +0 -38
- taichi/aot/conventions/gfxruntime140/dr.py +0 -244
- taichi/aot/conventions/gfxruntime140/sr.py +0 -613
- taichi/aot/module.py +0 -253
- taichi/aot/utils.py +0 -151
- taichi/graph/__init__.py +0 -3
- taichi/graph/_graph.py +0 -292
- taichi/lang/__init__.py +0 -50
- taichi/lang/ast/__init__.py +0 -5
- taichi/lang/ast/transform.py +0 -9
- taichi/lang/exception.py +0 -80
- taichi/linalg/__init__.py +0 -8
- taichi/profiler/__init__.py +0 -6
- taichi/shaders/Circles_vk.frag +0 -29
- taichi/shaders/Circles_vk.vert +0 -45
- taichi/shaders/Circles_vk_frag.spv +0 -0
- taichi/shaders/Circles_vk_vert.spv +0 -0
- taichi/shaders/Lines_vk.frag +0 -9
- taichi/shaders/Lines_vk.vert +0 -11
- taichi/shaders/Lines_vk_frag.spv +0 -0
- taichi/shaders/Lines_vk_vert.spv +0 -0
- taichi/shaders/Mesh_vk.frag +0 -71
- taichi/shaders/Mesh_vk.vert +0 -68
- taichi/shaders/Mesh_vk_frag.spv +0 -0
- taichi/shaders/Mesh_vk_vert.spv +0 -0
- taichi/shaders/Particles_vk.frag +0 -95
- taichi/shaders/Particles_vk.vert +0 -73
- taichi/shaders/Particles_vk_frag.spv +0 -0
- taichi/shaders/Particles_vk_vert.spv +0 -0
- taichi/shaders/SceneLines2quad_vk_comp.spv +0 -0
- taichi/shaders/SceneLines_vk.frag +0 -9
- taichi/shaders/SceneLines_vk.vert +0 -12
- taichi/shaders/SceneLines_vk_frag.spv +0 -0
- taichi/shaders/SceneLines_vk_vert.spv +0 -0
- taichi/shaders/SetImage_vk.frag +0 -21
- taichi/shaders/SetImage_vk.vert +0 -15
- taichi/shaders/SetImage_vk_frag.spv +0 -0
- taichi/shaders/SetImage_vk_vert.spv +0 -0
- taichi/shaders/Triangles_vk.frag +0 -16
- taichi/shaders/Triangles_vk.vert +0 -29
- taichi/shaders/Triangles_vk_frag.spv +0 -0
- taichi/shaders/Triangles_vk_vert.spv +0 -0
- taichi/shaders/lines2quad_vk_comp.spv +0 -0
- taichi/types/__init__.py +0 -19
- {taichi → gstaichi}/_lib/core/__init__.py +0 -0
- {taichi → gstaichi}/_lib/core/py.typed +0 -0
- {taichi/_lib/c_api → gstaichi/_lib}/runtime/slim_libdevice.10.bc +0 -0
- {taichi → gstaichi}/algorithms/__init__.py +0 -0
- {taichi → gstaichi}/assets/.git +0 -0
- {taichi → gstaichi}/assets/Go-Regular.ttf +0 -0
- {taichi → gstaichi}/assets/static/imgs/ti_gallery.png +0 -0
- {taichi → gstaichi}/lang/ast/symbol_resolver.py +0 -0
- {taichi → gstaichi}/sparse/__init__.py +0 -0
- {taichi → gstaichi}/tools/np2ply.py +0 -0
- {taichi → gstaichi}/tools/vtk.py +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools/cmake/SPIRV-ToolsConfig.cmake +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools/cmake/SPIRV-ToolsTarget-release.cmake +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools/cmake/SPIRV-ToolsTarget.cmake +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-diff/cmake/SPIRV-Tools-diffConfig.cmake +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-diff/cmake/SPIRV-Tools-diffTargets-release.cmake +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-diff/cmake/SPIRV-Tools-diffTargets.cmake +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-link/cmake/SPIRV-Tools-linkConfig.cmake +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-link/cmake/SPIRV-Tools-linkTargets-release.cmake +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-link/cmake/SPIRV-Tools-linkTargets.cmake +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-lint/cmake/SPIRV-Tools-lintConfig.cmake +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-lint/cmake/SPIRV-Tools-lintTargets-release.cmake +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-lint/cmake/SPIRV-Tools-lintTargets.cmake +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-opt/cmake/SPIRV-Tools-optConfig.cmake +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-opt/cmake/SPIRV-Tools-optTargets-release.cmake +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-opt/cmake/SPIRV-Tools-optTargets.cmake +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-reduce/cmake/SPIRV-Tools-reduceConfig.cmake +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-reduce/cmake/SPIRV-Tools-reduceTarget-release.cmake +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/SPIRV-Tools-reduce/cmake/SPIRV-Tools-reduceTarget.cmake +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/include/spirv-tools/instrument.hpp +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/include/spirv-tools/libspirv.h +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/include/spirv-tools/libspirv.hpp +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/include/spirv-tools/linker.hpp +0 -0
- {gstaichi-0.1.23.dev0.data → gstaichi-1.0.1.data}/data/include/spirv-tools/optimizer.hpp +0 -0
- {gstaichi-0.1.23.dev0.dist-info → gstaichi-1.0.1.dist-info}/WHEEL +0 -0
- {gstaichi-0.1.23.dev0.dist-info → gstaichi-1.0.1.dist-info}/licenses/LICENSE +0 -0
{taichi → gstaichi}/lang/ops.py
RENAMED
@@ -7,25 +7,30 @@ from typing import Union
|
|
7
7
|
|
8
8
|
import numpy as np
|
9
9
|
|
10
|
-
from
|
11
|
-
from
|
12
|
-
from
|
13
|
-
from
|
14
|
-
from
|
10
|
+
from gstaichi._lib import core as _ti_core
|
11
|
+
from gstaichi.lang import expr, impl
|
12
|
+
from gstaichi.lang.exception import GsTaichiSyntaxError
|
13
|
+
from gstaichi.lang.field import Field
|
14
|
+
from gstaichi.lang.util import (
|
15
|
+
cook_dtype,
|
16
|
+
gstaichi_scope,
|
17
|
+
is_gstaichi_class,
|
18
|
+
is_matrix_class,
|
19
|
+
)
|
15
20
|
|
16
21
|
|
17
22
|
def stack_info():
|
18
23
|
return impl.get_runtime().get_current_src_info()
|
19
24
|
|
20
25
|
|
21
|
-
def
|
26
|
+
def is_gstaichi_expr(a):
|
22
27
|
return isinstance(a, expr.Expr)
|
23
28
|
|
24
29
|
|
25
30
|
def wrap_if_not_expr(a):
|
26
31
|
return (
|
27
32
|
expr.Expr(a, dbg_info=_ti_core.DebugInfo(impl.get_runtime().get_current_src_info()))
|
28
|
-
if not
|
33
|
+
if not is_gstaichi_expr(a)
|
29
34
|
else a
|
30
35
|
)
|
31
36
|
|
@@ -41,8 +46,8 @@ def writeback_binary(foo):
|
|
41
46
|
def wrapped(a, b):
|
42
47
|
if isinstance(a, Field) or isinstance(b, Field):
|
43
48
|
return NotImplemented
|
44
|
-
if not (
|
45
|
-
raise
|
49
|
+
if not (is_gstaichi_expr(a) and a.ptr.is_lvalue()):
|
50
|
+
raise GsTaichiSyntaxError(f"cannot use a non-writable target as the first operand of '{foo.__name__}'")
|
46
51
|
return foo(a, wrap_if_not_expr(b))
|
47
52
|
|
48
53
|
return wrapped
|
@@ -50,13 +55,13 @@ def writeback_binary(foo):
|
|
50
55
|
|
51
56
|
def cast(obj, dtype):
|
52
57
|
"""Copy and cast a scalar or a matrix to a specified data type.
|
53
|
-
Must be called in
|
58
|
+
Must be called in GsTaichi scope.
|
54
59
|
|
55
60
|
Args:
|
56
|
-
obj (Union[:mod:`~
|
61
|
+
obj (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
57
62
|
Input scalar or matrix.
|
58
63
|
|
59
|
-
dtype (:mod:`~
|
64
|
+
dtype (:mod:`~gstaichi.types.primitive_types`): A primitive type defined in :mod:`~gstaichi.types.primitive_types`.
|
60
65
|
|
61
66
|
Returns:
|
62
67
|
A copy of `obj`, casted to the specified data type `dtype`.
|
@@ -73,7 +78,7 @@ def cast(obj, dtype):
|
|
73
78
|
[0.0, 1.0, 2.0]
|
74
79
|
"""
|
75
80
|
dtype = cook_dtype(dtype)
|
76
|
-
if
|
81
|
+
if is_gstaichi_class(obj):
|
77
82
|
# TODO: unify with element_wise_unary
|
78
83
|
return obj.cast(dtype)
|
79
84
|
return expr.Expr(_ti_core.value_cast(expr.Expr(obj).ptr, dtype))
|
@@ -81,14 +86,14 @@ def cast(obj, dtype):
|
|
81
86
|
|
82
87
|
def bit_cast(obj, dtype):
|
83
88
|
"""Copy and cast a scalar to a specified data type with its underlying
|
84
|
-
bits preserved. Must be called in
|
89
|
+
bits preserved. Must be called in gstaichi scope.
|
85
90
|
|
86
91
|
This function is equivalent to `reinterpret_cast` in C++.
|
87
92
|
|
88
93
|
Args:
|
89
|
-
obj (:mod:`~
|
94
|
+
obj (:mod:`~gstaichi.types.primitive_types`): Input scalar.
|
90
95
|
|
91
|
-
dtype (:mod:`~
|
96
|
+
dtype (:mod:`~gstaichi.types.primitive_types`): Target data type, must have \
|
92
97
|
the same precision bits as the input (hence `f32` -> `f64` is not allowed).
|
93
98
|
|
94
99
|
Returns:
|
@@ -106,44 +111,44 @@ def bit_cast(obj, dtype):
|
|
106
111
|
>>> print(z) # 3.14
|
107
112
|
"""
|
108
113
|
dtype = cook_dtype(dtype)
|
109
|
-
if
|
110
|
-
raise ValueError("Cannot apply bit_cast on
|
114
|
+
if is_gstaichi_class(obj):
|
115
|
+
raise ValueError("Cannot apply bit_cast on GsTaichi classes")
|
111
116
|
else:
|
112
117
|
return expr.Expr(_ti_core.bits_cast(expr.Expr(obj).ptr, dtype))
|
113
118
|
|
114
119
|
|
115
|
-
def _unary_operation(
|
120
|
+
def _unary_operation(gstaichi_op, python_op, a):
|
116
121
|
if isinstance(a, Field):
|
117
122
|
return NotImplemented
|
118
|
-
if
|
119
|
-
return expr.Expr(
|
120
|
-
from
|
123
|
+
if is_gstaichi_expr(a):
|
124
|
+
return expr.Expr(gstaichi_op(a.ptr), dbg_info=_ti_core.DebugInfo(stack_info()))
|
125
|
+
from gstaichi.lang.matrix import Matrix # pylint: disable-msg=C0415
|
121
126
|
|
122
127
|
if isinstance(a, Matrix):
|
123
128
|
return Matrix(python_op(a.to_numpy()))
|
124
129
|
return python_op(a)
|
125
130
|
|
126
131
|
|
127
|
-
def _binary_operation(
|
132
|
+
def _binary_operation(gstaichi_op, python_op, a, b):
|
128
133
|
if isinstance(a, Field) or isinstance(b, Field):
|
129
134
|
return NotImplemented
|
130
|
-
if
|
135
|
+
if is_gstaichi_expr(a) or is_gstaichi_expr(b):
|
131
136
|
a, b = wrap_if_not_expr(a), wrap_if_not_expr(b)
|
132
|
-
return expr.Expr(
|
133
|
-
from
|
137
|
+
return expr.Expr(gstaichi_op(a.ptr, b.ptr), dbg_info=_ti_core.DebugInfo(stack_info()))
|
138
|
+
from gstaichi.lang.matrix import Matrix # pylint: disable-msg=C0415
|
134
139
|
|
135
140
|
if isinstance(a, Matrix) or isinstance(b, Matrix):
|
136
141
|
return Matrix(python_op(_read_matrix_or_scalar(a), _read_matrix_or_scalar(b)))
|
137
142
|
return python_op(a, b)
|
138
143
|
|
139
144
|
|
140
|
-
def _ternary_operation(
|
145
|
+
def _ternary_operation(gstaichi_op, python_op, a, b, c):
|
141
146
|
if isinstance(a, Field) or isinstance(b, Field) or isinstance(c, Field):
|
142
147
|
return NotImplemented
|
143
|
-
if
|
148
|
+
if is_gstaichi_expr(a) or is_gstaichi_expr(b) or is_gstaichi_expr(c):
|
144
149
|
a, b, c = wrap_if_not_expr(a), wrap_if_not_expr(b), wrap_if_not_expr(c)
|
145
|
-
return expr.Expr(
|
146
|
-
from
|
150
|
+
return expr.Expr(gstaichi_op(a.ptr, b.ptr, c.ptr), dbg_info=_ti_core.DebugInfo(stack_info()))
|
151
|
+
from gstaichi.lang.matrix import Matrix # pylint: disable-msg=C0415
|
147
152
|
|
148
153
|
if isinstance(a, Matrix) or isinstance(b, Matrix) or isinstance(c, Matrix):
|
149
154
|
return Matrix(
|
@@ -160,7 +165,7 @@ def neg(x):
|
|
160
165
|
"""Numerical negative, element-wise.
|
161
166
|
|
162
167
|
Args:
|
163
|
-
x (Union[:mod:`~
|
168
|
+
x (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
164
169
|
Input scalar or matrix.
|
165
170
|
|
166
171
|
Returns:
|
@@ -179,7 +184,7 @@ def sin(x):
|
|
179
184
|
"""Trigonometric sine, element-wise.
|
180
185
|
|
181
186
|
Args:
|
182
|
-
x (Union[:mod:`~
|
187
|
+
x (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
183
188
|
Angle, in radians.
|
184
189
|
|
185
190
|
Returns:
|
@@ -199,7 +204,7 @@ def cos(x):
|
|
199
204
|
"""Trigonometric cosine, element-wise.
|
200
205
|
|
201
206
|
Args:
|
202
|
-
x (Union[:mod:`~
|
207
|
+
x (Union[:mod:`~gstaichi.type.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
203
208
|
Angle, in radians.
|
204
209
|
|
205
210
|
Returns:
|
@@ -221,10 +226,10 @@ def asin(x):
|
|
221
226
|
The inverse of `sin` so that, if `y = sin(x)`, then `x = asin(y)`.
|
222
227
|
|
223
228
|
For input `x` not in the domain `[-1, 1]`, this function returns `nan` if \
|
224
|
-
it's called in
|
229
|
+
it's called in gstaichi scope, or raises exception if it's called in python scope.
|
225
230
|
|
226
231
|
Args:
|
227
|
-
x (Union[:mod:`~
|
232
|
+
x (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
228
233
|
A scalar or a matrix with elements in [-1, 1].
|
229
234
|
|
230
235
|
Returns:
|
@@ -246,10 +251,10 @@ def acos(x):
|
|
246
251
|
The inverse of `cos` so that, if `y = cos(x)`, then `x = acos(y)`.
|
247
252
|
|
248
253
|
For input `x` not in the domain `[-1, 1]`, this function returns `nan` if \
|
249
|
-
it's called in
|
254
|
+
it's called in gstaichi scope, or raises exception if it's called in python scope.
|
250
255
|
|
251
256
|
Args:
|
252
|
-
x (Union[:mod:`~
|
257
|
+
x (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
253
258
|
A scalar or a matrix with elements in [-1, 1].
|
254
259
|
|
255
260
|
Returns:
|
@@ -270,7 +275,7 @@ def sqrt(x):
|
|
270
275
|
element wise. If `x < 0` an exception is raised.
|
271
276
|
|
272
277
|
Args:
|
273
|
-
x (Union[:mod:`~
|
278
|
+
x (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
274
279
|
The scalar or matrix whose square-roots are required.
|
275
280
|
|
276
281
|
Returns:
|
@@ -290,7 +295,7 @@ def rsqrt(x):
|
|
290
295
|
"""The reciprocal of the square root function.
|
291
296
|
|
292
297
|
Args:
|
293
|
-
x (Union[:mod:`~
|
298
|
+
x (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
294
299
|
A scalar or a matrix.
|
295
300
|
|
296
301
|
Returns:
|
@@ -311,10 +316,10 @@ def round(x, dtype=None): # pylint: disable=redefined-builtin
|
|
311
316
|
"""Round to the nearest integer, element-wise.
|
312
317
|
|
313
318
|
Args:
|
314
|
-
x (Union[:mod:`~
|
319
|
+
x (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
315
320
|
A scalar or a matrix.
|
316
321
|
|
317
|
-
dtype: (:mod:`~
|
322
|
+
dtype: (:mod:`~gstaichi.types.primitive_types`): the returned type, default to `None`. If \
|
318
323
|
set to `None` the retuned value will have the same type with `x`.
|
319
324
|
|
320
325
|
Returns:
|
@@ -343,10 +348,10 @@ def floor(x, dtype=None):
|
|
343
348
|
The floor of the scalar `x` is the largest integer `k`, such that `k <= x`.
|
344
349
|
|
345
350
|
Args:
|
346
|
-
x (Union[:mod:`~
|
351
|
+
x (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
347
352
|
Input scalar or matrix.
|
348
353
|
|
349
|
-
dtype: (:mod:`~
|
354
|
+
dtype: (:mod:`~gstaichi.types.primitive_types`): the returned type, default to `None`. If \
|
350
355
|
set to `None` the retuned value will have the same type with `x`.
|
351
356
|
|
352
357
|
Returns:
|
@@ -375,10 +380,10 @@ def ceil(x, dtype=None):
|
|
375
380
|
The ceil of the scalar `x` is the smallest integer `k`, such that `k >= x`.
|
376
381
|
|
377
382
|
Args:
|
378
|
-
x (Union[:mod:`~
|
383
|
+
x (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
379
384
|
Input scalar or matrix.
|
380
385
|
|
381
|
-
dtype: (:mod:`~
|
386
|
+
dtype: (:mod:`~gstaichi.types.primitive_types`): the returned type, default to `None`. If \
|
382
387
|
set to `None` the retuned value will have the same type with `x`.
|
383
388
|
|
384
389
|
Returns:
|
@@ -408,7 +413,7 @@ def tan(x):
|
|
408
413
|
Equivalent to `ti.sin(x)/ti.cos(x)` element-wise.
|
409
414
|
|
410
415
|
Args:
|
411
|
-
x (Union[:mod:`~
|
416
|
+
x (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
412
417
|
Input scalar or matrix.
|
413
418
|
|
414
419
|
Returns:
|
@@ -433,7 +438,7 @@ def tanh(x):
|
|
433
438
|
"""Compute the hyperbolic tangent of `x`, element-wise.
|
434
439
|
|
435
440
|
Args:
|
436
|
-
x (Union[:mod:`~
|
441
|
+
x (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
437
442
|
Input scalar or matrix.
|
438
443
|
|
439
444
|
Returns:
|
@@ -457,7 +462,7 @@ def exp(x):
|
|
457
462
|
"""Compute the exponential of all elements in `x`, element-wise.
|
458
463
|
|
459
464
|
Args:
|
460
|
-
x (Union[:mod:`~
|
465
|
+
x (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
461
466
|
Input scalar or matrix.
|
462
467
|
|
463
468
|
Returns:
|
@@ -484,7 +489,7 @@ def log(x):
|
|
484
489
|
so that `log(exp(x)) = x`. The natural logarithm is logarithm in base `e`.
|
485
490
|
|
486
491
|
Args:
|
487
|
-
x (Union[:mod:`~
|
492
|
+
x (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
488
493
|
Input scalar or matrix.
|
489
494
|
|
490
495
|
Returns:
|
@@ -508,7 +513,7 @@ def abs(x): # pylint: disable=W0622
|
|
508
513
|
"""Compute the absolute value :math:`|x|` of `x`, element-wise.
|
509
514
|
|
510
515
|
Args:
|
511
|
-
x (Union[:mod:`~
|
516
|
+
x (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
512
517
|
Input scalar or matrix.
|
513
518
|
|
514
519
|
Returns:
|
@@ -532,7 +537,7 @@ def bit_not(a):
|
|
532
537
|
"""The bit not function.
|
533
538
|
|
534
539
|
Args:
|
535
|
-
a (Union[:class:`~
|
540
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): A number or a matrix.
|
536
541
|
|
537
542
|
Returns:
|
538
543
|
Bitwise not of `a`.
|
@@ -551,7 +556,7 @@ def logical_not(a):
|
|
551
556
|
"""The logical not function.
|
552
557
|
|
553
558
|
Args:
|
554
|
-
a (Union[:class:`~
|
559
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): A number or a matrix.
|
555
560
|
|
556
561
|
Returns:
|
557
562
|
`1` iff `a=0`, otherwise `0`.
|
@@ -561,7 +566,7 @@ def logical_not(a):
|
|
561
566
|
|
562
567
|
def random(dtype=float) -> Union[float, int]:
|
563
568
|
"""Return a single random float/integer according to the specified data type.
|
564
|
-
Must be called in
|
569
|
+
Must be called in gstaichi scope.
|
565
570
|
|
566
571
|
If the required `dtype` is float type, this function returns a random number
|
567
572
|
sampled from the uniform distribution in the half-open interval [0, 1).
|
@@ -572,7 +577,7 @@ def random(dtype=float) -> Union[float, int]:
|
|
572
577
|
64-bit integer is required.
|
573
578
|
|
574
579
|
Args:
|
575
|
-
dtype (:mod:`~
|
580
|
+
dtype (:mod:`~gstaichi.types.primitive_types`): Type of the required random value.
|
576
581
|
|
577
582
|
Returns:
|
578
583
|
A random value with type `dtype`.
|
@@ -605,8 +610,8 @@ def add(a, b):
|
|
605
610
|
"""The add function.
|
606
611
|
|
607
612
|
Args:
|
608
|
-
a (Union[:class:`~
|
609
|
-
b (Union[:class:`~
|
613
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): A number or a matrix.
|
614
|
+
b (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): A number or a matrix.
|
610
615
|
|
611
616
|
Returns:
|
612
617
|
sum of `a` and `b`.
|
@@ -618,8 +623,8 @@ def sub(a, b):
|
|
618
623
|
"""The sub function.
|
619
624
|
|
620
625
|
Args:
|
621
|
-
a (Union[:class:`~
|
622
|
-
b (Union[:class:`~
|
626
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): A number or a matrix.
|
627
|
+
b (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): A number or a matrix.
|
623
628
|
|
624
629
|
Returns:
|
625
630
|
`a` subtract `b`.
|
@@ -631,8 +636,8 @@ def mul(a, b):
|
|
631
636
|
"""The multiply function.
|
632
637
|
|
633
638
|
Args:
|
634
|
-
a (Union[:class:`~
|
635
|
-
b (Union[:class:`~
|
639
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): A number or a matrix.
|
640
|
+
b (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): A number or a matrix.
|
636
641
|
|
637
642
|
Returns:
|
638
643
|
`a` multiplied by `b`.
|
@@ -647,10 +652,10 @@ def mod(x1, x2):
|
|
647
652
|
has the same sign as the divisor x2.
|
648
653
|
|
649
654
|
Args:
|
650
|
-
x1 (Union[:mod:`~
|
655
|
+
x1 (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
651
656
|
Dividend scalar or matrix.
|
652
657
|
|
653
|
-
x2 (Union[:mod:`~
|
658
|
+
x2 (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
654
659
|
Divisor scalar or matrix. When both `x1` and `x2` are matrices they must have the same shape.
|
655
660
|
|
656
661
|
Returns:
|
@@ -696,9 +701,9 @@ def pow(base, exponent): # pylint: disable=W0622
|
|
696
701
|
- A zero value raised to a non-positive value.
|
697
702
|
|
698
703
|
Args:
|
699
|
-
base (Union[:mod:`~
|
704
|
+
base (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
700
705
|
The bases.
|
701
|
-
exponent (Union[:mod:`~
|
706
|
+
exponent (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
702
707
|
The exponents.
|
703
708
|
|
704
709
|
Returns:
|
@@ -723,8 +728,8 @@ def floordiv(a, b):
|
|
723
728
|
"""The floor division function.
|
724
729
|
|
725
730
|
Args:
|
726
|
-
a (Union[:class:`~
|
727
|
-
b (Union[:class:`~
|
731
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): A number or a matrix.
|
732
|
+
b (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): A number or a matrix with elements not equal to zero.
|
728
733
|
|
729
734
|
Returns:
|
730
735
|
The floor function of `a` divided by `b`.
|
@@ -736,8 +741,8 @@ def truediv(a, b):
|
|
736
741
|
"""True division function.
|
737
742
|
|
738
743
|
Args:
|
739
|
-
a (Union[:class:`~
|
740
|
-
b (Union[:class:`~
|
744
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): A number or a matrix.
|
745
|
+
b (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): A number or a matrix with elements not equal to zero.
|
741
746
|
|
742
747
|
Returns:
|
743
748
|
The true value of `a` divided by `b`.
|
@@ -749,8 +754,8 @@ def max_impl(a, b):
|
|
749
754
|
"""The maxnimum function.
|
750
755
|
|
751
756
|
Args:
|
752
|
-
a (Union[:class:`~
|
753
|
-
b (Union[:class:`~
|
757
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): A number or a matrix.
|
758
|
+
b (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): A number or a matrix.
|
754
759
|
|
755
760
|
Returns:
|
756
761
|
The maxnimum of `a` and `b`.
|
@@ -762,8 +767,8 @@ def min_impl(a, b):
|
|
762
767
|
"""The minimum function.
|
763
768
|
|
764
769
|
Args:
|
765
|
-
a (Union[:class:`~
|
766
|
-
b (Union[:class:`~
|
770
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): A number or a matrix.
|
771
|
+
b (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): A number or a matrix.
|
767
772
|
|
768
773
|
Returns:
|
769
774
|
The minimum of `a` and `b`.
|
@@ -775,9 +780,9 @@ def atan2(x1, x2):
|
|
775
780
|
"""Element-wise arc tangent of `x1/x2`.
|
776
781
|
|
777
782
|
Args:
|
778
|
-
x1 (Union[:mod:`~
|
783
|
+
x1 (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
779
784
|
y-coordinates.
|
780
|
-
x2 (Union[:mod:`~
|
785
|
+
x2 (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
781
786
|
x-coordinates.
|
782
787
|
|
783
788
|
Returns:
|
@@ -804,8 +809,8 @@ def raw_div(x1, x2):
|
|
804
809
|
"""Return `x1 // x2` if both `x1`, `x2` are integers, otherwise return `x1/x2`.
|
805
810
|
|
806
811
|
Args:
|
807
|
-
x1 (Union[:mod:`~
|
808
|
-
x2 (Union[:mod:`~
|
812
|
+
x1 (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): Dividend.
|
813
|
+
x2 (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): Divisor.
|
809
814
|
|
810
815
|
Returns:
|
811
816
|
Return `x1 // x2` if both `x1`, `x2` are integers, otherwise return `x1/x2`.
|
@@ -834,9 +839,9 @@ def raw_mod(x1, x2):
|
|
834
839
|
This is the C-style `mod` function.
|
835
840
|
|
836
841
|
Args:
|
837
|
-
x1 (Union[:mod:`~
|
842
|
+
x1 (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
838
843
|
The dividend.
|
839
|
-
x2 (Union[:mod:`~
|
844
|
+
x2 (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
840
845
|
The divisor.
|
841
846
|
|
842
847
|
Returns:
|
@@ -860,11 +865,11 @@ def cmp_lt(a, b):
|
|
860
865
|
"""Compare two values (less than)
|
861
866
|
|
862
867
|
Args:
|
863
|
-
a (Union[:class:`~
|
864
|
-
b (Union[:class:`~
|
868
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value LHS
|
869
|
+
b (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value RHS
|
865
870
|
|
866
871
|
Returns:
|
867
|
-
Union[:class:`~
|
872
|
+
Union[:class:`~gstaichi.lang.expr.Expr`, bool]: True if LHS is strictly smaller than RHS, False otherwise
|
868
873
|
|
869
874
|
"""
|
870
875
|
return _binary_operation(_ti_core.expr_cmp_lt, _bt_ops_mod.lt, a, b)
|
@@ -874,11 +879,11 @@ def cmp_le(a, b):
|
|
874
879
|
"""Compare two values (less than or equal to)
|
875
880
|
|
876
881
|
Args:
|
877
|
-
a (Union[:class:`~
|
878
|
-
b (Union[:class:`~
|
882
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value LHS
|
883
|
+
b (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value RHS
|
879
884
|
|
880
885
|
Returns:
|
881
|
-
Union[:class:`~
|
886
|
+
Union[:class:`~gstaichi.lang.expr.Expr`, bool]: True if LHS is smaller than or equal to RHS, False otherwise
|
882
887
|
|
883
888
|
"""
|
884
889
|
return _binary_operation(_ti_core.expr_cmp_le, _bt_ops_mod.le, a, b)
|
@@ -888,11 +893,11 @@ def cmp_gt(a, b):
|
|
888
893
|
"""Compare two values (greater than)
|
889
894
|
|
890
895
|
Args:
|
891
|
-
a (Union[:class:`~
|
892
|
-
b (Union[:class:`~
|
896
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value LHS
|
897
|
+
b (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value RHS
|
893
898
|
|
894
899
|
Returns:
|
895
|
-
Union[:class:`~
|
900
|
+
Union[:class:`~gstaichi.lang.expr.Expr`, bool]: True if LHS is strictly larger than RHS, False otherwise
|
896
901
|
|
897
902
|
"""
|
898
903
|
return _binary_operation(_ti_core.expr_cmp_gt, _bt_ops_mod.gt, a, b)
|
@@ -902,8 +907,8 @@ def cmp_ge(a, b):
|
|
902
907
|
"""Compare two values (greater than or equal to)
|
903
908
|
|
904
909
|
Args:
|
905
|
-
a (Union[:class:`~
|
906
|
-
b (Union[:class:`~
|
910
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value LHS
|
911
|
+
b (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value RHS
|
907
912
|
|
908
913
|
Returns:
|
909
914
|
bool: True if LHS is greater than or equal to RHS, False otherwise
|
@@ -916,11 +921,11 @@ def cmp_eq(a, b):
|
|
916
921
|
"""Compare two values (equal to)
|
917
922
|
|
918
923
|
Args:
|
919
|
-
a (Union[:class:`~
|
920
|
-
b (Union[:class:`~
|
924
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value LHS
|
925
|
+
b (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value RHS
|
921
926
|
|
922
927
|
Returns:
|
923
|
-
Union[:class:`~
|
928
|
+
Union[:class:`~gstaichi.lang.expr.Expr`, bool]: True if LHS is equal to RHS, False otherwise.
|
924
929
|
|
925
930
|
"""
|
926
931
|
return _binary_operation(_ti_core.expr_cmp_eq, _bt_ops_mod.eq, a, b)
|
@@ -930,11 +935,11 @@ def cmp_ne(a, b):
|
|
930
935
|
"""Compare two values (not equal to)
|
931
936
|
|
932
937
|
Args:
|
933
|
-
a (Union[:class:`~
|
934
|
-
b (Union[:class:`~
|
938
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value LHS
|
939
|
+
b (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value RHS
|
935
940
|
|
936
941
|
Returns:
|
937
|
-
Union[:class:`~
|
942
|
+
Union[:class:`~gstaichi.lang.expr.Expr`, bool]: True if LHS is not equal to RHS, False otherwise
|
938
943
|
|
939
944
|
"""
|
940
945
|
return _binary_operation(_ti_core.expr_cmp_ne, _bt_ops_mod.ne, a, b)
|
@@ -944,11 +949,11 @@ def bit_or(a, b):
|
|
944
949
|
"""Computes bitwise-or
|
945
950
|
|
946
951
|
Args:
|
947
|
-
a (Union[:class:`~
|
948
|
-
b (Union[:class:`~
|
952
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value LHS
|
953
|
+
b (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value RHS
|
949
954
|
|
950
955
|
Returns:
|
951
|
-
Union[:class:`~
|
956
|
+
Union[:class:`~gstaichi.lang.expr.Expr`, bool]: LHS bitwise-or with RHS
|
952
957
|
|
953
958
|
"""
|
954
959
|
return _binary_operation(_ti_core.expr_bit_or, _bt_ops_mod.or_, a, b)
|
@@ -958,11 +963,11 @@ def bit_and(a, b):
|
|
958
963
|
"""Compute bitwise-and
|
959
964
|
|
960
965
|
Args:
|
961
|
-
a (Union[:class:`~
|
962
|
-
b (Union[:class:`~
|
966
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value LHS
|
967
|
+
b (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value RHS
|
963
968
|
|
964
969
|
Returns:
|
965
|
-
Union[:class:`~
|
970
|
+
Union[:class:`~gstaichi.lang.expr.Expr`, bool]: LHS bitwise-and with RHS
|
966
971
|
|
967
972
|
"""
|
968
973
|
return _binary_operation(_ti_core.expr_bit_and, _bt_ops_mod.and_, a, b)
|
@@ -972,11 +977,11 @@ def bit_xor(a, b):
|
|
972
977
|
"""Compute bitwise-xor
|
973
978
|
|
974
979
|
Args:
|
975
|
-
a (Union[:class:`~
|
976
|
-
b (Union[:class:`~
|
980
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value LHS
|
981
|
+
b (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value RHS
|
977
982
|
|
978
983
|
Returns:
|
979
|
-
Union[:class:`~
|
984
|
+
Union[:class:`~gstaichi.lang.expr.Expr`, bool]: LHS bitwise-xor with RHS
|
980
985
|
|
981
986
|
"""
|
982
987
|
return _binary_operation(_ti_core.expr_bit_xor, _bt_ops_mod.xor, a, b)
|
@@ -986,11 +991,11 @@ def bit_shl(a, b):
|
|
986
991
|
"""Compute bitwise shift left
|
987
992
|
|
988
993
|
Args:
|
989
|
-
a (Union[:class:`~
|
990
|
-
b (Union[:class:`~
|
994
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value LHS
|
995
|
+
b (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value RHS
|
991
996
|
|
992
997
|
Returns:
|
993
|
-
Union[:class:`~
|
998
|
+
Union[:class:`~gstaichi.lang.expr.Expr`, int]: LHS << RHS
|
994
999
|
|
995
1000
|
"""
|
996
1001
|
return _binary_operation(_ti_core.expr_bit_shl, _bt_ops_mod.lshift, a, b)
|
@@ -1000,25 +1005,25 @@ def bit_sar(a, b):
|
|
1000
1005
|
"""Compute bitwise shift right
|
1001
1006
|
|
1002
1007
|
Args:
|
1003
|
-
a (Union[:class:`~
|
1004
|
-
b (Union[:class:`~
|
1008
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value LHS
|
1009
|
+
b (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value RHS
|
1005
1010
|
|
1006
1011
|
Returns:
|
1007
|
-
Union[:class:`~
|
1012
|
+
Union[:class:`~gstaichi.lang.expr.Expr`, int]: LHS >> RHS
|
1008
1013
|
|
1009
1014
|
"""
|
1010
1015
|
return _binary_operation(_ti_core.expr_bit_sar, _bt_ops_mod.rshift, a, b)
|
1011
1016
|
|
1012
1017
|
|
1013
|
-
@
|
1018
|
+
@gstaichi_scope
|
1014
1019
|
def bit_shr(x1, x2):
|
1015
1020
|
"""Elements in `x1` shifted to the right by number of bits in `x2`.
|
1016
1021
|
Both `x1`, `x2` must have integer type.
|
1017
1022
|
|
1018
1023
|
Args:
|
1019
|
-
x1 (Union[:mod:`~
|
1024
|
+
x1 (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
1020
1025
|
Input data.
|
1021
|
-
x2 (Union[:mod:`~
|
1026
|
+
x2 (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
1022
1027
|
Number of bits to remove at the right of `x1`.
|
1023
1028
|
|
1024
1029
|
Returns:
|
@@ -1042,11 +1047,11 @@ def logical_and(a, b):
|
|
1042
1047
|
"""Compute logical_and
|
1043
1048
|
|
1044
1049
|
Args:
|
1045
|
-
a (Union[:class:`~
|
1046
|
-
b (Union[:class:`~
|
1050
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value LHS
|
1051
|
+
b (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value RHS
|
1047
1052
|
|
1048
1053
|
Returns:
|
1049
|
-
Union[:class:`~
|
1054
|
+
Union[:class:`~gstaichi.lang.expr.Expr`, bool]: LHS logical-and RHS (with short-circuit semantics)
|
1050
1055
|
|
1051
1056
|
"""
|
1052
1057
|
return _binary_operation(_ti_core.expr_logical_and, lambda a, b: a and b, a, b)
|
@@ -1056,11 +1061,11 @@ def logical_or(a, b):
|
|
1056
1061
|
"""Compute logical_or
|
1057
1062
|
|
1058
1063
|
Args:
|
1059
|
-
a (Union[:class:`~
|
1060
|
-
b (Union[:class:`~
|
1064
|
+
a (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value LHS
|
1065
|
+
b (Union[:class:`~gstaichi.lang.expr.Expr`, :class:`~gstaichi.lang.matrix.Matrix`]): value RHS
|
1061
1066
|
|
1062
1067
|
Returns:
|
1063
|
-
Union[:class:`~
|
1068
|
+
Union[:class:`~gstaichi.lang.expr.Expr`, bool]: LHS logical-or RHS (with short-circuit semantics)
|
1064
1069
|
|
1065
1070
|
"""
|
1066
1071
|
return _binary_operation(_ti_core.expr_logical_or, lambda a, b: a or b, a, b)
|
@@ -1071,9 +1076,9 @@ def select(cond, x1, x2):
|
|
1071
1076
|
depending on the conditions in `cond`.
|
1072
1077
|
|
1073
1078
|
Args:
|
1074
|
-
cond (Union[:mod:`~
|
1079
|
+
cond (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
1075
1080
|
The array of conditions.
|
1076
|
-
x1, x2 (Union[:mod:`~
|
1081
|
+
x1, x2 (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
1077
1082
|
The arrays where the output elements are taken from.
|
1078
1083
|
|
1079
1084
|
Returns:
|
@@ -1106,9 +1111,9 @@ def ifte(cond, x1, x2):
|
|
1106
1111
|
short-circuit semantics: exactly one of `x1` or `x2` will be evaluated.
|
1107
1112
|
|
1108
1113
|
Args:
|
1109
|
-
cond (:mod:`~
|
1114
|
+
cond (:mod:`~gstaichi.types.primitive_types`): \
|
1110
1115
|
The condition.
|
1111
|
-
x1, x2 (:mod:`~
|
1116
|
+
x1, x2 (:mod:`~gstaichi.types.primitive_types`): \
|
1112
1117
|
The outputs.
|
1113
1118
|
|
1114
1119
|
Returns:
|
@@ -1144,7 +1149,7 @@ def atomic_add(x, y):
|
|
1144
1149
|
are not allowed.
|
1145
1150
|
|
1146
1151
|
Args:
|
1147
|
-
x, y (Union[:mod:`~
|
1152
|
+
x, y (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
1148
1153
|
The input.
|
1149
1154
|
|
1150
1155
|
Returns:
|
@@ -1160,7 +1165,7 @@ def atomic_add(x, y):
|
|
1160
1165
|
>>> print(x) # [1, 2, 3] the new value of x
|
1161
1166
|
>>> print(z) # [0, 0, 0], the old value of x
|
1162
1167
|
>>>
|
1163
|
-
>>> ti.atomic_add(1, x) # will raise
|
1168
|
+
>>> ti.atomic_add(1, x) # will raise GsTaichiSyntaxError
|
1164
1169
|
"""
|
1165
1170
|
return impl.expr_init(expr.Expr(_ti_core.expr_atomic_add(x.ptr, y.ptr), dbg_info=_ti_core.DebugInfo(stack_info())))
|
1166
1171
|
|
@@ -1174,7 +1179,7 @@ def atomic_mul(x, y):
|
|
1174
1179
|
are not allowed.
|
1175
1180
|
|
1176
1181
|
Args:
|
1177
|
-
x, y (Union[:mod:`~
|
1182
|
+
x, y (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
1178
1183
|
The input.
|
1179
1184
|
|
1180
1185
|
Returns:
|
@@ -1190,7 +1195,7 @@ def atomic_mul(x, y):
|
|
1190
1195
|
>>> print(x) # [1, 2, 3] the new value of x
|
1191
1196
|
>>> print(z) # [4, 10, 18], the old value of x
|
1192
1197
|
>>>
|
1193
|
-
>>> ti.atomic_mul(1, x) # will raise
|
1198
|
+
>>> ti.atomic_mul(1, x) # will raise GsTaichiSyntaxError
|
1194
1199
|
"""
|
1195
1200
|
return impl.expr_init(expr.Expr(_ti_core.expr_atomic_mul(x.ptr, y.ptr), dbg_info=_ti_core.DebugInfo(stack_info())))
|
1196
1201
|
|
@@ -1204,7 +1209,7 @@ def atomic_sub(x, y):
|
|
1204
1209
|
are not allowed.
|
1205
1210
|
|
1206
1211
|
Args:
|
1207
|
-
x, y (Union[:mod:`~
|
1212
|
+
x, y (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
1208
1213
|
The input.
|
1209
1214
|
|
1210
1215
|
Returns:
|
@@ -1220,7 +1225,7 @@ def atomic_sub(x, y):
|
|
1220
1225
|
>>> print(x) # [-1, -2, -3] the new value of x
|
1221
1226
|
>>> print(z) # [0, 0, 0], the old value of x
|
1222
1227
|
>>>
|
1223
|
-
>>> ti.atomic_sub(1, x) # will raise
|
1228
|
+
>>> ti.atomic_sub(1, x) # will raise GsTaichiSyntaxError
|
1224
1229
|
"""
|
1225
1230
|
return impl.expr_init(expr.Expr(_ti_core.expr_atomic_sub(x.ptr, y.ptr), dbg_info=_ti_core.DebugInfo(stack_info())))
|
1226
1231
|
|
@@ -1234,7 +1239,7 @@ def atomic_min(x, y):
|
|
1234
1239
|
are not allowed.
|
1235
1240
|
|
1236
1241
|
Args:
|
1237
|
-
x, y (Union[:mod:`~
|
1242
|
+
x, y (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
1238
1243
|
The input.
|
1239
1244
|
|
1240
1245
|
Returns:
|
@@ -1250,7 +1255,7 @@ def atomic_min(x, y):
|
|
1250
1255
|
>>> print(x) # 1 the new value of x
|
1251
1256
|
>>> print(z) # 2, the old value of x
|
1252
1257
|
>>>
|
1253
|
-
>>> ti.atomic_min(1, x) # will raise
|
1258
|
+
>>> ti.atomic_min(1, x) # will raise GsTaichiSyntaxError
|
1254
1259
|
"""
|
1255
1260
|
return impl.expr_init(expr.Expr(_ti_core.expr_atomic_min(x.ptr, y.ptr), dbg_info=_ti_core.DebugInfo(stack_info())))
|
1256
1261
|
|
@@ -1264,7 +1269,7 @@ def atomic_max(x, y):
|
|
1264
1269
|
are not allowed.
|
1265
1270
|
|
1266
1271
|
Args:
|
1267
|
-
x, y (Union[:mod:`~
|
1272
|
+
x, y (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
1268
1273
|
The input.
|
1269
1274
|
|
1270
1275
|
Returns:
|
@@ -1280,7 +1285,7 @@ def atomic_max(x, y):
|
|
1280
1285
|
>>> print(x) # 2 the new value of x
|
1281
1286
|
>>> print(z) # 1, the old value of x
|
1282
1287
|
>>>
|
1283
|
-
>>> ti.atomic_max(1, x) # will raise
|
1288
|
+
>>> ti.atomic_max(1, x) # will raise GsTaichiSyntaxError
|
1284
1289
|
"""
|
1285
1290
|
return impl.expr_init(expr.Expr(_ti_core.expr_atomic_max(x.ptr, y.ptr), dbg_info=_ti_core.DebugInfo(stack_info())))
|
1286
1291
|
|
@@ -1294,7 +1299,7 @@ def atomic_and(x, y):
|
|
1294
1299
|
are not allowed.
|
1295
1300
|
|
1296
1301
|
Args:
|
1297
|
-
x, y (Union[:mod:`~
|
1302
|
+
x, y (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
1298
1303
|
The input. When both are matrices they must have the same shape.
|
1299
1304
|
|
1300
1305
|
Returns:
|
@@ -1310,7 +1315,7 @@ def atomic_and(x, y):
|
|
1310
1315
|
>>> print(x) # [1, 0, 1] the new value of x
|
1311
1316
|
>>> print(z) # [-1, 0, 1], the old value of x
|
1312
1317
|
>>>
|
1313
|
-
>>> ti.atomic_and(1, x) # will raise
|
1318
|
+
>>> ti.atomic_and(1, x) # will raise GsTaichiSyntaxError
|
1314
1319
|
"""
|
1315
1320
|
return impl.expr_init(
|
1316
1321
|
expr.Expr(_ti_core.expr_atomic_bit_and(x.ptr, y.ptr), dbg_info=_ti_core.DebugInfo(stack_info()))
|
@@ -1326,7 +1331,7 @@ def atomic_or(x, y):
|
|
1326
1331
|
are not allowed.
|
1327
1332
|
|
1328
1333
|
Args:
|
1329
|
-
x, y (Union[:mod:`~
|
1334
|
+
x, y (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
1330
1335
|
The input. When both are matrices they must have the same shape.
|
1331
1336
|
|
1332
1337
|
Returns:
|
@@ -1342,7 +1347,7 @@ def atomic_or(x, y):
|
|
1342
1347
|
>>> print(x) # [-1, 2, 3] the new value of x
|
1343
1348
|
>>> print(z) # [-1, 0, 1], the old value of x
|
1344
1349
|
>>>
|
1345
|
-
>>> ti.atomic_or(1, x) # will raise
|
1350
|
+
>>> ti.atomic_or(1, x) # will raise GsTaichiSyntaxError
|
1346
1351
|
"""
|
1347
1352
|
return impl.expr_init(
|
1348
1353
|
expr.Expr(_ti_core.expr_atomic_bit_or(x.ptr, y.ptr), dbg_info=_ti_core.DebugInfo(stack_info()))
|
@@ -1358,7 +1363,7 @@ def atomic_xor(x, y):
|
|
1358
1363
|
are not allowed.
|
1359
1364
|
|
1360
1365
|
Args:
|
1361
|
-
x, y (Union[:mod:`~
|
1366
|
+
x, y (Union[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
1362
1367
|
The input. When both are matrices they must have the same shape.
|
1363
1368
|
|
1364
1369
|
Returns:
|
@@ -1374,7 +1379,7 @@ def atomic_xor(x, y):
|
|
1374
1379
|
>>> print(x) # [-2, 2, 2] the new value of x
|
1375
1380
|
>>> print(z) # [-1, 0, 1], the old value of x
|
1376
1381
|
>>>
|
1377
|
-
>>> ti.atomic_xor(1, x) # will raise
|
1382
|
+
>>> ti.atomic_xor(1, x) # will raise GsTaichiSyntaxError
|
1378
1383
|
"""
|
1379
1384
|
return impl.expr_init(
|
1380
1385
|
expr.Expr(_ti_core.expr_atomic_bit_xor(x.ptr, y.ptr), dbg_info=_ti_core.DebugInfo(stack_info()))
|
@@ -1395,7 +1400,7 @@ def max(*args): # pylint: disable=W0622
|
|
1395
1400
|
must have the same shape, and scalars will be broadcasted to the same shape as the matrix.
|
1396
1401
|
|
1397
1402
|
Args:
|
1398
|
-
args: (List[:mod:`~
|
1403
|
+
args: (List[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
1399
1404
|
The input.
|
1400
1405
|
|
1401
1406
|
Returns:
|
@@ -1427,7 +1432,7 @@ def min(*args): # pylint: disable=W0622
|
|
1427
1432
|
must have the same shape, and scalars will be broadcasted to the same shape as the matrix.
|
1428
1433
|
|
1429
1434
|
Args:
|
1430
|
-
args: (List[:mod:`~
|
1435
|
+
args: (List[:mod:`~gstaichi.types.primitive_types`, :class:`~gstaichi.Matrix`]): \
|
1431
1436
|
The input.
|
1432
1437
|
|
1433
1438
|
Returns:
|