torch_npu.npu.Event().recorded_time () -> int
获取NPU Event对象在设备上被记录的时间。
成员函数使用时必须是NPU Event对象才能调用。
输出被记录的时间,是一个无符号的整数(uint64)。
“INTERNALError”- Event对象必须在获取记录时间戳之前被记录。
Event对象在创建的时候,需要传入参数enable_timing=True。
1 2 3 4 5 6 | import torch import torch_npu event = torch.npu.Event(enable_timing=True) event.record() res = event.recorded_time() |