taichi.tools
¶
Submodules¶
Package Contents¶
Classes¶
Functions¶
|
Try to display image in interactive shell. |
|
Load image from a specific file. |
|
Resize an image to a specific size. |
|
Show image in a Taichi GUI. |
|
Save a field to a a specific file. |
|
Print warning message |
|
Mark an API as deprecated. |
|
Mark an API as obsolete. Usage: |
|
|
|
|
Print time elapsed on the host tasks in a hierarchical format. |
|
Clear profiler's records about time elapsed on the host tasks. |
|
|
|
|
|
- taichi.tools.imdisplay(img)¶
Try to display image in interactive shell.
- Parameters
img (Union[ti.field, np.ndarray]) – A field of of array with shape (width, height) or (height, width, 3) or (height, width, 4).
- taichi.tools.imread(filename, channels=0)¶
Load image from a specific file.
- Parameters
filename (str) – An image filename to load from.
channels (int, optinal) – The channels hint of input image, Default to 0.
- Returns
An output image loaded from given filename.
- Return type
np.ndarray
- taichi.tools.imresize(img, w, h=None)¶
Resize an image to a specific size.
- Parameters
img (Union[ti.field, np.ndarray]) – A field of of array with shape (width, height, …)
w (int) – The output width after resize.
h (int, optional) – The output height after resize, will be the same as width if not set. Default to None.
- Returns
An output image after resize input.
- Return type
np.ndarray
- taichi.tools.imshow(img, window_name='imshow')¶
Show image in a Taichi GUI.
- Parameters
img (Union[ti.field, np.ndarray]) – A field of of array with shape (width, height) or (height, width, 3) or (height, width, 4).
window_name (str, optional) – The title of GUI window. Default to imshow.
- taichi.tools.imwrite(img, filename)¶
Save a field to a a specific file.
- Parameters
img (Union[ti.field, np.ndarray]) – A field of shape (height, width) or (height, width, 3) or (height, width, 4), if dtype is float-type (ti.f16, ti.f32, np.float32 etc), the value of each pixel should be float between [0.0, 1.0]. Otherwise ti.imwrite will first clip them into [0.0, 1.0] if dtype is int-type (ti.u8, ti.u16, np.uint8 etc), , the value of each pixel can be any valid integer in its own bounds. These integers in this field will be scaled to [0, 255] by being divided over the upper bound of its basic type accordingly.
filename (str) – The filename to save to.
- class taichi.tools.PLYWriter(num_vertices: int, num_faces=0, face_type='tri', comment='created by PLYWriter')¶
- add_vertex_channel(self, key: str, data_type: str, data: numpy.array)¶
- add_vertex_pos(self, x: numpy.array, y: numpy.array, z: numpy.array)¶
- add_vertex_normal(self, nx: numpy.array, ny: numpy.array, nz: numpy.array)¶
- add_vertex_color(self, r: numpy.array, g: numpy.array, b: numpy.array)¶
- add_vertex_alpha(self, alpha: numpy.array)¶
- add_vertex_rgba(self, r: numpy.array, g: numpy.array, b: numpy.array, a: numpy.array)¶
- add_vertex_id(self)¶
- add_vertex_piece(self, piece: numpy.array)¶
- add_faces(self, indices: numpy.array)¶
- add_face_channel(self, key: str, data_type: str, data: numpy.array)¶
- add_face_id(self)¶
- add_face_piece(self, piece: numpy.array)¶
- sanity_check(self)¶
- print_header(self, path: str, _format: str)¶
- export(self, path)¶
- export_ascii(self, path)¶
- export_frame_ascii(self, series_num: int, path: str)¶
- export_frame(self, series_num: int, path: str)¶
- taichi.tools.warning(msg, warning_type=UserWarning, stacklevel=1)¶
Print warning message
- Parameters
msg (str) – massage to print.
warning_type (builtin warning type) – type of warning.
stacklevel (int) – warning stack level from the caller.
- taichi.tools.deprecated(old, new, warning_type=DeprecationWarning)¶
Mark an API as deprecated.
- Parameters
old (str) – old method.
new (str) – new method.
warning_type (builtin warning type) – type of warning.
Example:
>>> @deprecated('ti.sqr(x)', 'x**2') >>> def sqr(x): >>> return x**2
- Returns
Decorated fuction with warning message
- taichi.tools.obsolete(old, new)¶
Mark an API as obsolete. Usage:
sqr = obsolete(‘ti.sqr(x)’, ‘x**2’)
- taichi.tools.get_traceback(stacklevel=1)¶
- taichi.tools.set_gdb_trigger(on=True)¶
- taichi.tools.print_profile_info()¶
Print time elapsed on the host tasks in a hierarchical format.
This profiler is automatically on.
Call function imports from C++ : _ti_core.print_profile_info()
Example:
>>> import taichi as ti >>> ti.init(arch=ti.cpu) >>> var = ti.field(ti.f32, shape=1) >>> @ti.kernel >>> def compute(): >>> var[0] = 1.0 >>> print("Setting var[0] =", var[0]) >>> compute() >>> ti.print_profile_info()
- taichi.tools.clear_profile_info()¶
Clear profiler’s records about time elapsed on the host tasks.
Call function imports from C++ : _ti_core.clear_profile_info()
- taichi.tools.dump_dot(filepath=None, rankdir=None, embed_states_threshold=0)¶
- taichi.tools.dot_to_pdf(dot, filepath)¶
- taichi.tools.get_kernel_stats()¶