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/_ti_module/cppgen.py
DELETED
@@ -1,309 +0,0 @@
|
|
1
|
-
# type: ignore
|
2
|
-
|
3
|
-
from typing import Any, List, Optional, Set
|
4
|
-
|
5
|
-
from taichi.aot.conventions.gfxruntime140 import GfxRuntime140, sr
|
6
|
-
|
7
|
-
dtype2ctype = {
|
8
|
-
sr.DataType.f16: "half_t",
|
9
|
-
sr.DataType.f32: "float",
|
10
|
-
sr.DataType.f64: "double",
|
11
|
-
sr.DataType.i8: "int8_t",
|
12
|
-
sr.DataType.i16: "int16_t",
|
13
|
-
sr.DataType.i32: "int32_t",
|
14
|
-
sr.DataType.i64: "int64_t",
|
15
|
-
sr.DataType.u8: "uint8_t",
|
16
|
-
sr.DataType.u16: "uint16_t",
|
17
|
-
sr.DataType.u32: "uint32_t",
|
18
|
-
sr.DataType.u64: "uint64_t",
|
19
|
-
}
|
20
|
-
|
21
|
-
|
22
|
-
def check_arg(actual: str, expect: Any) -> List[str]:
|
23
|
-
out = []
|
24
|
-
|
25
|
-
expect = str(expect)
|
26
|
-
out += [
|
27
|
-
f" if (value.{actual} != {expect}) {{",
|
28
|
-
f' ti_set_last_error(TI_ERROR_INVALID_ARGUMENT, "value.{actual} != {expect}");',
|
29
|
-
" return *this;",
|
30
|
-
" }",
|
31
|
-
]
|
32
|
-
|
33
|
-
return out
|
34
|
-
|
35
|
-
|
36
|
-
def get_arg_dst(i: int, is_named: bool) -> str:
|
37
|
-
if is_named:
|
38
|
-
return f"args_[{i}].argument"
|
39
|
-
return f"args_[{i}]"
|
40
|
-
|
41
|
-
|
42
|
-
def generate_scalar_assign(cls_name: str, i: int, arg_name: str, arg: sr.ArgumentScalar, is_named: bool) -> List[str]:
|
43
|
-
ctype = dtype2ctype[arg.dtype]
|
44
|
-
|
45
|
-
out = []
|
46
|
-
|
47
|
-
out += [
|
48
|
-
f" {cls_name} &set_{arg_name}({ctype} value) {{",
|
49
|
-
]
|
50
|
-
|
51
|
-
if is_named:
|
52
|
-
out += [
|
53
|
-
f' args_[{i}].name = "{arg_name}";',
|
54
|
-
]
|
55
|
-
if ctype == "float":
|
56
|
-
out += [
|
57
|
-
f" {get_arg_dst(i, is_named)}.type = TI_ARGUMENT_TYPE_F32;",
|
58
|
-
f" {get_arg_dst(i, is_named)}.value.f32 = value;",
|
59
|
-
]
|
60
|
-
elif ctype == "int32_t":
|
61
|
-
out += [
|
62
|
-
f" {get_arg_dst(i, is_named)}.type = TI_ARGUMENT_TYPE_I32;",
|
63
|
-
f" {get_arg_dst(i, is_named)}.value.i32 = value;",
|
64
|
-
]
|
65
|
-
else:
|
66
|
-
out += [
|
67
|
-
f" {get_arg_dst(i, is_named)}.type = TI_ARGUMENT_TYPE_SCALAR;",
|
68
|
-
f" {get_arg_dst(i, is_named)}.value.scalar.type = TI_DATA_TYPE_{arg.dtype.name.upper()};",
|
69
|
-
f" *(({ctype}*)(&{get_arg_dst(i, is_named)}.value.scalar.value)) = value;",
|
70
|
-
]
|
71
|
-
assert False, f"{ctype} is not a supported scalar type."
|
72
|
-
|
73
|
-
out += [
|
74
|
-
" return *this;",
|
75
|
-
" }",
|
76
|
-
]
|
77
|
-
return out
|
78
|
-
|
79
|
-
|
80
|
-
def generate_ndarray_assign(cls_name: str, i: int, arg_name: str, arg: sr.ArgumentNdArray, is_named: bool) -> List[str]:
|
81
|
-
out = []
|
82
|
-
|
83
|
-
out += [
|
84
|
-
f" {cls_name} &set_{arg_name}(const TiNdArray &value) {{",
|
85
|
-
]
|
86
|
-
|
87
|
-
out += check_arg("elem_type", f"TI_DATA_TYPE_{arg.dtype.name.upper()}")
|
88
|
-
out += check_arg("shape.dim_count", arg.ndim)
|
89
|
-
assert len(arg.element_shape) <= 16
|
90
|
-
out += check_arg("elem_shape.dim_count", len(arg.element_shape))
|
91
|
-
for j, dim in enumerate(arg.element_shape):
|
92
|
-
out += check_arg(f"elem_shape.dims[{j}]", dim)
|
93
|
-
|
94
|
-
if is_named:
|
95
|
-
out += [
|
96
|
-
f' args_[{i}].name = "{arg_name}";',
|
97
|
-
]
|
98
|
-
out += [
|
99
|
-
f" {get_arg_dst(i, is_named)}.type = TI_ARGUMENT_TYPE_NDARRAY;",
|
100
|
-
f" {get_arg_dst(i, is_named)}.value.ndarray = value;",
|
101
|
-
" return *this;",
|
102
|
-
" }",
|
103
|
-
]
|
104
|
-
return out
|
105
|
-
|
106
|
-
|
107
|
-
def generate_texture_assign(
|
108
|
-
cls_name: str,
|
109
|
-
i: int,
|
110
|
-
arg_name: str,
|
111
|
-
arg: sr.ArgumentTexture | sr.ArgumentRwTexture,
|
112
|
-
is_named: bool,
|
113
|
-
) -> List[str]:
|
114
|
-
out = []
|
115
|
-
|
116
|
-
out += [
|
117
|
-
f" {cls_name} &set_{arg_name}(const TiTexture &value) {{",
|
118
|
-
]
|
119
|
-
|
120
|
-
assert arg.ndim in [1, 2, 3]
|
121
|
-
out += check_arg("dimension", f"TI_IMAGE_DIMENSION_{arg.ndim}D")
|
122
|
-
if isinstance(arg, sr.ArgumentRwTexture):
|
123
|
-
out += check_arg("format", f"TI_FORMAT_{arg.fmt.name.upper()}")
|
124
|
-
|
125
|
-
if is_named:
|
126
|
-
out += [
|
127
|
-
f' args_[{i}].name = "{arg_name}";',
|
128
|
-
]
|
129
|
-
out += [
|
130
|
-
f" {get_arg_dst(i, is_named)}.type = TI_ARGUMENT_TYPE_TEXTURE;",
|
131
|
-
f" {get_arg_dst(i, is_named)}.value.texture = value;",
|
132
|
-
" return *this;",
|
133
|
-
" }",
|
134
|
-
]
|
135
|
-
return out
|
136
|
-
|
137
|
-
|
138
|
-
def generate_kernel_args_builder(kernel: sr.Kernel) -> List[str]:
|
139
|
-
out = []
|
140
|
-
|
141
|
-
out += [
|
142
|
-
f"struct Kernel_{kernel.name} : public ti::Kernel {{",
|
143
|
-
f" explicit Kernel_{kernel.name}(TiRuntime runtime, TiKernel kernel) :",
|
144
|
-
" ti::Kernel(runtime, kernel) {",
|
145
|
-
f" args_.resize({len(kernel.context.args)});",
|
146
|
-
" }",
|
147
|
-
"",
|
148
|
-
]
|
149
|
-
|
150
|
-
cls_name = f"Kernel_{kernel.name}"
|
151
|
-
for i, arg in enumerate(kernel.context.args):
|
152
|
-
arg_name = arg.name if arg.name else f"arg{i}"
|
153
|
-
if isinstance(arg, sr.ArgumentScalar):
|
154
|
-
out += generate_scalar_assign(cls_name, i, arg_name, arg, False)
|
155
|
-
elif isinstance(arg, sr.ArgumentNdArray):
|
156
|
-
out += generate_ndarray_assign(cls_name, i, arg_name, arg, False)
|
157
|
-
elif isinstance(arg, (sr.ArgumentTexture, sr.ArgumentRwTexture)):
|
158
|
-
out += generate_texture_assign(cls_name, i, arg_name, arg, False)
|
159
|
-
else:
|
160
|
-
assert False
|
161
|
-
out += [""]
|
162
|
-
|
163
|
-
out += [
|
164
|
-
"};",
|
165
|
-
"",
|
166
|
-
]
|
167
|
-
return out
|
168
|
-
|
169
|
-
|
170
|
-
def generate_graph_args_builder(graph: sr.Graph) -> List[str]:
|
171
|
-
out = []
|
172
|
-
|
173
|
-
out += [
|
174
|
-
f"struct ComputeGraph_{graph.name} : public ti::ComputeGraph {{",
|
175
|
-
f" explicit ComputeGraph_{graph.name}(TiRuntime runtime, TiComputeGraph graph) :",
|
176
|
-
" ti::ComputeGraph(runtime, graph) {",
|
177
|
-
f" args_.resize({len(graph.args)});",
|
178
|
-
" }",
|
179
|
-
"",
|
180
|
-
]
|
181
|
-
|
182
|
-
cls_name = f"ComputeGraph_{graph.name}"
|
183
|
-
for i, arg in enumerate(graph.args):
|
184
|
-
arg_name = arg.name
|
185
|
-
if isinstance(arg.arg, sr.ArgumentScalar):
|
186
|
-
out += generate_scalar_assign(cls_name, i, arg_name, arg.arg, True)
|
187
|
-
elif isinstance(arg.arg, sr.ArgumentNdArray):
|
188
|
-
out += generate_ndarray_assign(cls_name, i, arg_name, arg.arg, True)
|
189
|
-
elif isinstance(arg.arg, (sr.ArgumentTexture, sr.ArgumentRwTexture)):
|
190
|
-
out += generate_texture_assign(cls_name, i, arg_name, arg.arg, True)
|
191
|
-
else:
|
192
|
-
assert False
|
193
|
-
out += [""]
|
194
|
-
|
195
|
-
out += [
|
196
|
-
"};",
|
197
|
-
"",
|
198
|
-
]
|
199
|
-
return out
|
200
|
-
|
201
|
-
|
202
|
-
def generate_module_content_repr(m: GfxRuntime140, module_name: str, cgraph_kernel_names: Set[str]) -> List[str]:
|
203
|
-
out = []
|
204
|
-
|
205
|
-
if module_name:
|
206
|
-
module_name = f"AotModule_{module_name}"
|
207
|
-
else:
|
208
|
-
module_name = "AotModule"
|
209
|
-
|
210
|
-
out += [
|
211
|
-
f"struct {module_name} : public ti::AotModule {{",
|
212
|
-
f" explicit {module_name}(TiRuntime runtime, TiAotModule aot_module, bool should_destroy = true) :",
|
213
|
-
" ti::AotModule(runtime, aot_module, should_destroy) {}",
|
214
|
-
"",
|
215
|
-
f" static {module_name} load(TiRuntime runtime, const char *path) {{",
|
216
|
-
" TiAotModule aot_module = ti_load_aot_module(runtime, path);",
|
217
|
-
f" return {module_name}(runtime, aot_module, true);",
|
218
|
-
" }",
|
219
|
-
f" static {module_name} load(TiRuntime runtime, const std::string &path) {{",
|
220
|
-
f" return {module_name}::load(runtime, path.c_str());",
|
221
|
-
" }",
|
222
|
-
f" static {module_name} create(TiRuntime runtime, const void *tcm, size_t size) {{",
|
223
|
-
" TiAotModule aot_module = ti_create_aot_module(runtime, tcm, size);",
|
224
|
-
f" return {module_name}(runtime, aot_module, true);",
|
225
|
-
" }",
|
226
|
-
f" static {module_name} create(TiRuntime runtime, const std::vector<uint8_t> &tcm) {{",
|
227
|
-
f" return {module_name}::create(runtime, tcm.data(), tcm.size());",
|
228
|
-
" }",
|
229
|
-
"",
|
230
|
-
]
|
231
|
-
for kernel in m.metadata.kernels.values():
|
232
|
-
if kernel.name in cgraph_kernel_names:
|
233
|
-
continue
|
234
|
-
out += [
|
235
|
-
f" Kernel_{kernel.name} get_kernel_{kernel.name}() const {{",
|
236
|
-
f' return Kernel_{kernel.name}(runtime_, ti_get_aot_module_kernel(aot_module(), "{kernel.name}"));',
|
237
|
-
" }",
|
238
|
-
]
|
239
|
-
for graph in m.graphs:
|
240
|
-
out += [
|
241
|
-
f" ComputeGraph_{graph.name} get_compute_graph_{graph.name}() const {{",
|
242
|
-
f' return ComputeGraph_{graph.name}(runtime_, ti_get_aot_module_compute_graph(aot_module(), "{graph.name}"));',
|
243
|
-
" }",
|
244
|
-
]
|
245
|
-
out += [
|
246
|
-
"};",
|
247
|
-
"",
|
248
|
-
]
|
249
|
-
return out
|
250
|
-
|
251
|
-
|
252
|
-
def generate_module_content(m: GfxRuntime140, module_name: str) -> List[str]:
|
253
|
-
# This has all kernels including all the ones launched by compute graphs.
|
254
|
-
cgraph_kernel_names = set(dispatch.kernel.name for graph in m.graphs for dispatch in graph.dispatches)
|
255
|
-
|
256
|
-
out = []
|
257
|
-
for kernel in m.metadata.kernels.values():
|
258
|
-
if kernel.name in cgraph_kernel_names:
|
259
|
-
continue
|
260
|
-
out += generate_kernel_args_builder(kernel)
|
261
|
-
|
262
|
-
for graph in m.graphs:
|
263
|
-
out += generate_graph_args_builder(graph)
|
264
|
-
|
265
|
-
out += generate_module_content_repr(m, module_name, cgraph_kernel_names)
|
266
|
-
|
267
|
-
return out
|
268
|
-
|
269
|
-
|
270
|
-
def generate_header(m: GfxRuntime140, module_name: str, namespace: str, tcm: Optional[bytes]) -> List[str]:
|
271
|
-
out = []
|
272
|
-
|
273
|
-
out += [
|
274
|
-
"// THIS IS A GENERATED HEADER; PLEASE DO NOT MODIFY.",
|
275
|
-
"#pragma once",
|
276
|
-
"#include <vector>",
|
277
|
-
"#include <string>",
|
278
|
-
"#include <taichi/cpp/taichi.hpp>",
|
279
|
-
"",
|
280
|
-
]
|
281
|
-
|
282
|
-
if namespace:
|
283
|
-
out += [
|
284
|
-
f"namespace {namespace} {{",
|
285
|
-
"",
|
286
|
-
]
|
287
|
-
|
288
|
-
if tcm is not None:
|
289
|
-
tcm_bytes = [x for x in tcm]
|
290
|
-
|
291
|
-
out += [
|
292
|
-
f"static const uint8_t {module_name}_tcm[{len(tcm_bytes)}] = {{",
|
293
|
-
]
|
294
|
-
|
295
|
-
out += [f" {', '.join(str(x) for x in tcm_bytes[i:i + 8])}," for i in range(0, len(tcm_bytes), 8)]
|
296
|
-
|
297
|
-
out += [
|
298
|
-
"};",
|
299
|
-
"",
|
300
|
-
f"static const size_t {module_name}_tcm_size = {len(tcm_bytes)};",
|
301
|
-
"",
|
302
|
-
]
|
303
|
-
|
304
|
-
out += generate_module_content(m, module_name)
|
305
|
-
|
306
|
-
if namespace:
|
307
|
-
out += [f"}} // namespace {namespace}", ""]
|
308
|
-
|
309
|
-
return out
|
taichi/_ti_module/module.py
DELETED
@@ -1,145 +0,0 @@
|
|
1
|
-
# type: ignore
|
2
|
-
|
3
|
-
import argparse
|
4
|
-
import runpy
|
5
|
-
from pathlib import Path
|
6
|
-
from typing import List
|
7
|
-
|
8
|
-
import taichi
|
9
|
-
from taichi._ti_module.cppgen import generate_header
|
10
|
-
from taichi.aot._export import _aot_kernels
|
11
|
-
from taichi.aot.conventions.gfxruntime140 import GfxRuntime140
|
12
|
-
from taichi.aot.module import Module
|
13
|
-
from taichi.types.ndarray_type import NdarrayType
|
14
|
-
from taichi.types.primitive_types import integer_type_ids, real_type_ids
|
15
|
-
from taichi.types.texture_type import RWTextureType, TextureType
|
16
|
-
|
17
|
-
|
18
|
-
def module_cppgen(parser: argparse.ArgumentParser):
|
19
|
-
"""Generate C++ headers for Taichi modules."""
|
20
|
-
parser.add_argument("MODOLE", help="Path to the module directory.")
|
21
|
-
parser.add_argument("-n", "--namespace", type=str, help="C++ namespace if wanted.")
|
22
|
-
parser.add_argument(
|
23
|
-
"-m",
|
24
|
-
"--module-name",
|
25
|
-
type=str,
|
26
|
-
help="Module name to be a part of the module class. By default, it's the directory name.",
|
27
|
-
default=None,
|
28
|
-
)
|
29
|
-
parser.add_argument("-o", "--output", type=str, help="Output C++ header path.", default="module.h")
|
30
|
-
parser.add_argument(
|
31
|
-
"--bin2c",
|
32
|
-
help="Save the entire TCM archive to an in-memory buffer. This flag is ignored if the module is not a TCM archive",
|
33
|
-
action="store_true",
|
34
|
-
)
|
35
|
-
parser.set_defaults(func=module_cppgen_impl)
|
36
|
-
|
37
|
-
|
38
|
-
def module_cppgen_impl(a):
|
39
|
-
module_path = a.MODOLE
|
40
|
-
|
41
|
-
print(f"Generating C++ header for Taichi module: {Path(module_path).absolute()}")
|
42
|
-
|
43
|
-
tcm = None
|
44
|
-
if a.bin2c and module_path.endswith(".tcm"):
|
45
|
-
with open(module_path, "rb") as f:
|
46
|
-
tcm = f.read()
|
47
|
-
|
48
|
-
if a.module_name:
|
49
|
-
module_name = a.module_name
|
50
|
-
else:
|
51
|
-
module_name = Path(module_path).name
|
52
|
-
if module_name.endswith(".tcm"):
|
53
|
-
module_name = module_name[:-4]
|
54
|
-
|
55
|
-
m = GfxRuntime140.from_module(module_path)
|
56
|
-
|
57
|
-
out = generate_header(m, module_name, a.namespace, tcm)
|
58
|
-
|
59
|
-
with open(a.output, "w") as f:
|
60
|
-
f.write("\n".join(out))
|
61
|
-
|
62
|
-
print(f"Module header is saved to: {Path(a.output).absolute()}")
|
63
|
-
|
64
|
-
|
65
|
-
def module_build(parser: argparse.ArgumentParser):
|
66
|
-
"""Build Taichi modules from python scripts."""
|
67
|
-
parser.add_argument("SOURCE", help="Path to the Taichi program source (Python script).")
|
68
|
-
parser.add_argument("-o", "--output", type=str, help="Output module path.", default=None)
|
69
|
-
parser.set_defaults(func=module_build_impl)
|
70
|
-
|
71
|
-
|
72
|
-
def module_build_impl(a):
|
73
|
-
source_path = a.SOURCE
|
74
|
-
module_path = a.output
|
75
|
-
|
76
|
-
source_path = Path(source_path)
|
77
|
-
assert source_path.name.endswith(".py"), "Source must be a Python script."
|
78
|
-
if module_path is None:
|
79
|
-
module_path = f"{source_path.name[:-3]}.tcm"
|
80
|
-
module_path = Path(module_path)
|
81
|
-
|
82
|
-
print(f"Building Taichi module: {source_path}")
|
83
|
-
print()
|
84
|
-
|
85
|
-
d = runpy.run_path(str(source_path), run_name="__main__")
|
86
|
-
print()
|
87
|
-
|
88
|
-
required_caps = d["REQUIRED_CAPS"] if "REQUIRED_CAPS" in d else []
|
89
|
-
assert isinstance(required_caps, list), "REQUIRED_CAPS must be a list."
|
90
|
-
|
91
|
-
if required_caps:
|
92
|
-
print("Module requires the following capabilities:")
|
93
|
-
for cap in required_caps:
|
94
|
-
print(f" - {cap}")
|
95
|
-
print()
|
96
|
-
|
97
|
-
m = Module(caps=required_caps)
|
98
|
-
for record in _aot_kernels:
|
99
|
-
print("Added kernel:", record.name)
|
100
|
-
template_args = None
|
101
|
-
if record.template_types:
|
102
|
-
print(" Template types:")
|
103
|
-
template_args = {}
|
104
|
-
for k, v in record.template_types.items():
|
105
|
-
print(f" - {k}: {v}")
|
106
|
-
# TODO: (penguinliong) Remove this hack. It's not properly
|
107
|
-
# working with unusual numeric types like f16 or i64.
|
108
|
-
if isinstance(v, int) or id(v) in integer_type_ids:
|
109
|
-
value = 0
|
110
|
-
elif isinstance(v, float) or id(v) in real_type_ids:
|
111
|
-
value = 0.0
|
112
|
-
elif isinstance(v, NdarrayType):
|
113
|
-
if v.ndim is None or v.ndim <= 0:
|
114
|
-
raise ValueError("Ndarray template type must specify a non-zero dimension.")
|
115
|
-
value = taichi.ndarray(v.dtype, (1,) * v.ndim)
|
116
|
-
elif isinstance(v, TextureType):
|
117
|
-
value = taichi.Texture(taichi.Format.rgba8, (4,) * v.num_dimensions)
|
118
|
-
elif isinstance(v, RWTextureType):
|
119
|
-
value = taichi.Texture(v.fmt, (4,) * v.num_dimensions)
|
120
|
-
else:
|
121
|
-
raise ValueError(f"Unsupported template type: {type(v)}")
|
122
|
-
template_args[k] = value
|
123
|
-
m.add_kernel(record.kernel, template_args)
|
124
|
-
print()
|
125
|
-
|
126
|
-
if module_path.name.endswith(".tcm"):
|
127
|
-
m.archive(str(module_path))
|
128
|
-
else:
|
129
|
-
m.save(str(module_path))
|
130
|
-
|
131
|
-
print(f"Module is archive to: {module_path}")
|
132
|
-
print()
|
133
|
-
|
134
|
-
|
135
|
-
def _main(arguments: List[str]):
|
136
|
-
"""Taichi module tools."""
|
137
|
-
parser = argparse.ArgumentParser(prog="ti module", description=_main.__doc__)
|
138
|
-
subparsers = parser.add_subparsers(title="Taichi module manager commands", required=True)
|
139
|
-
|
140
|
-
cppgen_parser = subparsers.add_parser("cppgen", help=module_cppgen.__doc__)
|
141
|
-
build_parser = subparsers.add_parser("build", help=module_build.__doc__)
|
142
|
-
module_cppgen(cppgen_parser)
|
143
|
-
module_build(build_parser)
|
144
|
-
args = parser.parse_args(arguments)
|
145
|
-
args.func(args)
|
taichi/_version.py
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
__version__ = '0.1.23.dev0'
|
taichi/ad/__init__.py
DELETED
taichi/aot/__init__.py
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
# type: ignore
|
2
|
-
|
3
|
-
"""Taichi's AOT (ahead of time) module.
|
4
|
-
|
5
|
-
Users can use Taichi as a GPU compute shader/kernel compiler by compiling their
|
6
|
-
Taichi kernels into an AOT module.
|
7
|
-
"""
|
8
|
-
|
9
|
-
import taichi.aot.conventions
|
10
|
-
from taichi.aot._export import export, export_as
|
11
|
-
from taichi.aot.conventions.gfxruntime140 import GfxRuntime140
|
12
|
-
from taichi.aot.module import Module
|
taichi/aot/_export.py
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# type: ignore
|
2
|
-
|
3
|
-
from typing import Any, Dict, List, Optional
|
4
|
-
|
5
|
-
|
6
|
-
class AotExportKernel:
|
7
|
-
def __init__(self, f, name: str, template_types: Dict[str, Any]) -> None:
|
8
|
-
self.kernel = f
|
9
|
-
self.name = name
|
10
|
-
self.template_types = template_types
|
11
|
-
|
12
|
-
|
13
|
-
_aot_kernels: List[AotExportKernel] = []
|
14
|
-
|
15
|
-
|
16
|
-
def export_as(name: str, *, template_types: Optional[Dict[str, Any]] = None):
|
17
|
-
def inner(f):
|
18
|
-
assert hasattr(f, "_is_wrapped_kernel"), "Only Taichi kernels can be exported"
|
19
|
-
|
20
|
-
record = AotExportKernel(f, name, template_types or {})
|
21
|
-
_aot_kernels.append(record)
|
22
|
-
return f
|
23
|
-
|
24
|
-
return inner
|
25
|
-
|
26
|
-
|
27
|
-
def export(f):
|
28
|
-
return export_as(f.__name__)(f)
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# type: ignore
|
2
|
-
|
3
|
-
import json
|
4
|
-
import zipfile
|
5
|
-
from pathlib import Path
|
6
|
-
from typing import Any, List
|
7
|
-
|
8
|
-
from taichi.aot.conventions.gfxruntime140 import dr, sr
|
9
|
-
|
10
|
-
|
11
|
-
class GfxRuntime140:
|
12
|
-
def __init__(self, metadata_json: Any, graphs_json: Any) -> None:
|
13
|
-
metadata = dr.from_json_metadata(metadata_json)
|
14
|
-
graphs = [dr.from_json_graph(x) for x in graphs_json]
|
15
|
-
self.metadata = sr.from_dr_metadata(metadata)
|
16
|
-
self.graphs = [sr.from_dr_graph(self.metadata, x) for x in graphs]
|
17
|
-
|
18
|
-
@staticmethod
|
19
|
-
def from_module(module_path: str) -> "GfxRuntime140":
|
20
|
-
if Path(module_path).is_file():
|
21
|
-
with zipfile.ZipFile(module_path) as z:
|
22
|
-
with z.open("metadata.json") as f:
|
23
|
-
metadata_json = json.load(f)
|
24
|
-
with z.open("graphs.json") as f:
|
25
|
-
graphs_json = json.load(f)
|
26
|
-
else:
|
27
|
-
with open(f"{module_path}/metadata.json") as f:
|
28
|
-
metadata_json = json.load(f)
|
29
|
-
with open(f"{module_path}/graphs.json") as f:
|
30
|
-
graphs_json = json.load(f)
|
31
|
-
|
32
|
-
return GfxRuntime140(metadata_json, graphs_json)
|
33
|
-
|
34
|
-
def to_metadata_json(self) -> Any:
|
35
|
-
return dr.to_json_metadata(sr.to_dr_metadata(self.metadata))
|
36
|
-
|
37
|
-
def to_graphs_json(self) -> List[Any]:
|
38
|
-
return [dr.to_json_graph(sr.to_dr_graph(x)) for x in self.graphs]
|