Taichi: [Doc] add more details for debug utils and developer utils

Created on 17 Jun 2020  路  8Comments  路  Source: taichi-dev/taichi

Concisely describe the proposed feature
Sometimes I felt a little hard to develop Taichi because Our "developer utils" is not as powerful as we imagine.

For example ti.info this function lacks a clear statement, which means a fresh developer cannot learn from the doc for utils he may need.

And I realize that there are lots of functions that haven't been documented well, for example, ti.ti_print.

A clear and concise description of what you want.

I hope to consummate the "developer utils" parts such as for ti.info, add more details in it so that new developer can feel easier

I don't know whether ti.ti_print() has been deprecated or not. If not, I can add some details to it.

Also, I have realized that the backend of ti.info is spdlog. I am using it as well in my own project. spdlog should also support logging to a .log file, do we need to come up with a way to enable this feature in Taichi python-binding?

If we want to use Taichi in a big project, logging to file should be essential. Btw, if this has been supported, I can add a doc for it as well.


2020/06/18 update:

So after a brief discussion with @archibate , I realize that:

  1. ti_ti_print is not a developer util but debug util.
  2. Maybe we can try to add a new section for debug util, including but not limited to ti_print, ti_static_print and others about profiler
  3. I hope to add more details for ti.info in Developer util.

HDYT?

feature request

Most helpful comment

I think the same place as ti.static_print should be good enough.

All 8 comments

In fact, ti.ti_print should never be directly used, but in generated code from our AST transformer:
https://github.com/taichi-dev/taichi/blob/ca833ba0db05b58d5ebdc92acf38232b154b267c/python/taichi/lang/transformer.py#L547-L557

.. which transform every print in @ti.kernel to ti.ti_print where we have control.


You may learn more about Taichi AST preprocessor by run:

import taichi as ti
ti.init(print_preprocessed=True)

@ti.kernel
def func():
  x = 3
  x = x * 2
  print(x)

func()

You will obtain:

Before preprocessing:
@ti.kernel
def func():
    x = 3
    x = x * 2
    print(x)

After preprocessing:
def func():
  x = ti.expr_init(3)
  x.assign(x * 2)
  ti.ti_print(x)

See? Since the builtin print doesn't work in Taichi runtime, we have to translate these into Taichi ones.

It looks nice, thanks! I will learn more about this AST system.

Btw, are there still any other utils for debug purpose in out whole system?

Yes, assert for example. (btw, do we have ti.static_assert? that can be useful)

It seems...we don't have it at this moment. :( I search for the whole code repo, no.

Where should be a proper place to implement ti.static_assert?

I think the same place as ti.static_print should be good enough.

Good, Thanks!

What's the progress? You may open a PR in draft state to share progress :)

I will return to my dormitory 1 hour later and publish this draft PR ;-)

Was this page helpful?
0 / 5 - 0 ratings