mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Summary: Adding `test_tensorexpr.py` to our CI. There's a few complications: the first one is that we now always run `SimpleIREVal` as a part of simplifier, so the counts will always be greater than one. We can potentially invest some effort to differentiate between a real codegen call to `SimpleIREval` and calls in simplifier, but it's probably not that important and the second change to turn not being able to retrieve a counter into a default value of 0 since the test are structured to test for either an llvm or simpleireval backends, so it only seems appropriate to not fail the test too early. Pull Request resolved: https://github.com/pytorch/pytorch/pull/35776 Differential Revision: D20799333 Pulled By: Krovatkin fbshipit-source-id: 2a94ff98e647180c6e6aea141a411c3376c509f9
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
from __future__ import absolute_import
|
|
from __future__ import division
|
|
from __future__ import print_function
|
|
from __future__ import unicode_literals
|
|
|
|
import torch
|
|
|
|
class ExecutionCounter(object):
|
|
def try_get_trigger_value(self):
|
|
try:
|
|
return torch._C._jit_get_trigger_value(self.name)
|
|
except Exception:
|
|
return 0
|
|
|
|
def __init__(self, name):
|
|
self.name = name
|
|
self.start_value = self.try_get_trigger_value()
|
|
|
|
def elapsed_value(self):
|
|
value = self.try_get_trigger_value()
|
|
return value - self.start_value
|
|
|
|
class CudaCodeGenCreated(ExecutionCounter):
|
|
def __init__(self):
|
|
super(CudaCodeGenCreated, self).__init__("cuda_codegen_created")
|
|
|
|
class CudaCodeGenExecuted(ExecutionCounter):
|
|
def __init__(self):
|
|
super(CudaCodeGenExecuted, self).__init__("cuda_codegen_executed")
|
|
|
|
class LLVMCodeGenCreated(ExecutionCounter):
|
|
def __init__(self):
|
|
super(LLVMCodeGenCreated, self).__init__("llvm_codegen_created")
|
|
|
|
class LLVMCodeGenExecuted(ExecutionCounter):
|
|
def __init__(self):
|
|
super(LLVMCodeGenExecuted, self).__init__("llvm_codegen_executed")
|
|
|
|
class SimpleIREvalExecuted(ExecutionCounter):
|
|
def __init__(self):
|
|
super(SimpleIREvalExecuted, self).__init__("simple_ir_eval_executed")
|