Пример #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]
Пример #2
0
 def check(expr, vars={}):
     for k, v in vars.items():
         locals()[k] = int(v)
     _v1 = None
     _v2 = None
     try:
         _v1 = jit_eval(expr, vars)
     except:
         pass
     try:
         _v2 = eval(expr)
     except:
         pass
     LOG.vv(f"check {expr} = {_v1}, {_v2}, {_v1 == _v2}")
     assert _v1 == _v2
Пример #3
0
    def check_cc(self, content, check_movnt):
        LOG.vv("check_cc")
        with open(self.src_path, "w") as f:
            f.write(content)

        cmd = jt.flags.python_path + " " + \
            jt.flags.jittor_path+"/utils/asm_tuner.py --cc_path=" + jt.flags.cc_path + " '" + self.src_path + "'" + " -DJIT -DJIT_cpu " + jt.flags.cc_flags + " -o '" + self.so_path + "'"
        self.run_cmd(cmd)

        s_path = self.so_path.replace(".so", ".s")
        bo = False
        with open(s_path) as f:
            for line in f:
                if line.find("vmovnt") != -1:
                    bo = True
                    break
        if check_movnt and jt.flags.cc_type == "clang":
            assert bo