MCPcopy Index your code
hub / github.com/pytorch/tutorials / check_cl

Function check_cl

intermediate_source/memory_format_tutorial.py:329–354  ·  view source on GitHub ↗
(*args, **kwargs)

Source from the content-addressed store, hash-verified

327 name = fn.__name__
328
329 def check_cl(*args, **kwargs):
330 was_cl = contains_cl(args)
331 try:
332 result = fn(*args, **kwargs)
333 except Exception as e:
334 print("`{}` inputs are:".format(name))
335 print_inputs(args)
336 print("-------------------")
337 raise e
338 failed = False
339 if was_cl:
340 if isinstance(result, torch.Tensor):
341 if result.dim() == 4 and not result.is_contiguous(memory_format=torch.channels_last):
342 print(
343 "`{}` got channels_last input, but output is not channels_last:".format(name),
344 result.shape,
345 result.stride(),
346 result.device,
347 result.dtype,
348 )
349 failed = True
350 if failed and True:
351 print("`{}` inputs are:".format(name))
352 print_inputs(args)
353 raise Exception("Operator `{}` lost channels_last property".format(name))
354 return result
355
356 return check_cl
357

Callers

nothing calls this directly

Calls 3

contains_clFunction · 0.85
print_inputsFunction · 0.85
fnFunction · 0.70

Tested by

no test coverage detected