docstr: (custom() − baseline()) <= atol + rtol * abs(baseline)
docstr_tok: ["(","custom","(",")","\u2212","baseline","(",")",")","<","=","atol","+","rtol","*","abs","(","baseline",")"]
code: def test(self, custom, baseline, nrepeat, rtol, atol):
      """
      (custom() − baseline()) <= atol + rtol * abs(baseline)
      """
  
      def core(func):
          res = func()  # warmup for GPU
          self.assert_allclose(res, res, rtol, atol)
          timing = list()
          for i in range(nrepeat):
              torch.cuda.synchronize(device=self.device)
              begin = time.time()
              cur_res = func()
              torch.cuda.synchronize(device=self.device)
              # In seconds
              timing.append(time.time() - begin)
              self.assert_allclose(cur_res, res, rtol, atol)
          return res, np.mean(timing) * 1000
  
      print("Run baseline...")
      baseline_res, baseline_time = core(baseline)
      print("Run custom...")
      custom_res, custom_time = core(custom)
  
      print("Compare the results of custom and baseline...")
      self.assert_allclose(custom_res, baseline_res, rtol, atol)
      print(
          "Test passed. Time of custom/baseline (ms): %.3f / %.3f, speedup: %.3f"
          % (custom_time, baseline_time, baseline_time / custom_time)
      )
  
imports: import random
  import time
  from collections import OrderedDict
  import numpy
  import torch
label_desc: Use image node_id 25 for calling the TestDecorator obj's underlying member method code with example usage: obj.test(custom, baseline, nrepeat, rtol, atol) and returns: res,  unknown