예제 #1
0
    def test_log_capture(self):
        LOG.log_capture_start()
        with jt.var_scope(log_v=1000, log_vprefix=""):
            LOG.v("1")
            LOG.vv("2")
            LOG.i("3")
            LOG.w("4")
            LOG.e("5")
            a = jt.zeros([10])
            a.sync()
        LOG.log_capture_stop()
        # TODO: why need manually delete this variable?
        del a
        logs = LOG.log_capture_read()
        logs2 = LOG.log_capture_read()
        assert len(logs2) == 0

        for i in range(5):
            assert logs[i]['msg'] == str(i + 1)
            assert logs[i]['level'] == 'iiiwe'[i]
            assert logs[i]['name'] == 'test_log.py'
        finished_log = [
            l["msg"] for l in logs
            if l["name"] == "executor.cc" and "return vars:" in l["msg"]
        ]
        assert len(finished_log) == 1 and "[10,]" in finished_log[0]
 def inner(*args):
     for i in range(num):
         if i == num-1:
             func(*args)
             break
         try:
             func(*args)
             break
         except:
             pass
         LOG.v(f"Retry {i}")
예제 #3
0
 def test_mwsr_list(self):
     cc_flags = f" -g -O3 -DTEST --std=c++14 -I{jittor_path}/test -I{jittor_path}/src -lpthread "
     cmd = f"cd {cache_path} && g++ {jittor_path}/src/utils/mwsr_list.cc {cc_flags} -o mwsr_list && ./mwsr_list"
     LOG.v(cmd)
     assert os.system(cmd) == 0
예제 #4
0
 def test_log(self):
     cc_flags = f" -g -O3 -DTEST_LOG --std=c++14 -I{jittor_path}/test -I{jittor_path}/src -lpthread "
     cmd = f"cd {cache_path} && g++ {jittor_path}/src/utils/log.cc {jittor_path}/src/utils/tracer.cc {cc_flags} -o log && log_v=1000 log_sync=0 ./log"
     LOG.v(cmd)
     assert os.system(cmd) == 0