MCPcopy Create free account
hub / github.com/pytorch/pytorch / assertUfuncErrorInline

Method assertUfuncErrorInline

tools/test/test_codegen_model.py:34–62  ·  view source on GitHub ↗
(self, yaml_str: str, expect: str)

Source from the content-addressed store, hash-verified

32 self.fail(msg="Did not raise when expected to")
33
34 def assertUfuncErrorInline(self, yaml_str: str, expect: str) -> None:
35 # parse a single structured group out of the yaml to g
36 es = yaml.load(yaml_str, Loader=LineLoader)
37 parsed_yaml = parse_native_yaml_struct(es, set())
38 native_functions, backend_indices = (
39 parsed_yaml.native_functions,
40 parsed_yaml.backend_indices,
41 )
42 grouped_native_functions = gen.get_grouped_native_functions(native_functions)
43 assert len(grouped_native_functions) == 1
44 g = grouped_native_functions[0]
45 assert isinstance(g, NativeFunctionsGroup)
46 assert g.out.ufunc_inner_loop
47 # this is not ufunc codegen per se, but it does some basic sanity tests for
48 # ufunc generation
49 gen.compute_meta_function_declaration(g)
50 dest.compute_native_function_declaration(g, backend_indices[DispatchKey.CPU])
51 dest.compute_native_function_declaration(g, backend_indices[DispatchKey.CUDA])
52 try:
53 # the real kahuna
54 dest.compute_ufunc_cpu(g)
55 dest.compute_ufunc_cpu_kernel(g)
56 dest.compute_ufunc_cuda(g)
57 except AssertionError as e:
58 # hack to strip out the context
59 msg, _ = str(e).split(" in ", 2)
60 self.assertExpectedInline("\n".join(textwrap.wrap(msg)), expect, skip=1)
61 return
62 self.fail(msg="Did not raise when expected to")
63
64 # NB: indent is hardcoded to be two here, so format your yaml accordingly
65 binop_out = (

Calls 8

parse_native_yaml_structFunction · 0.90
isinstanceFunction · 0.85
assertExpectedInlineMethod · 0.80
loadMethod · 0.45
splitMethod · 0.45
joinMethod · 0.45
wrapMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected