MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / _get_valid_program

Function _get_valid_program

python/paddle/static/io_utils.py:62–81  ·  view source on GitHub ↗

return default main program if program is None.

(program=None)

Source from the content-addressed store, hash-verified

60
61
62def _get_valid_program(program=None):
63 """
64 return default main program if program is None.
65 """
66 if program is None:
67 program = paddle.static.default_main_program()
68 elif isinstance(program, CompiledProgram):
69 program = program._program
70 if program is None:
71 raise TypeError(
72 "The type of input program is invalid, expected type is Program, but received None"
73 )
74 warnings.warn(
75 "The input is a CompiledProgram, this is not recommended."
76 )
77 if not isinstance(program, paddle.static.Program):
78 raise TypeError(
79 f"The type of input program is invalid, expected type is base.Program, but received {type(program)}"
80 )
81 return program
82
83
84def _safe_load_pickle(file, encoding="ASCII"):

Callers 6

serialize_programFunction · 0.70
serialize_persistablesFunction · 0.70
save_inference_modelFunction · 0.70
save_varsFunction · 0.70
save_vars_pirFunction · 0.70
save_inference_model_pirFunction · 0.70

Calls 3

TypeErrorClass · 0.85
typeFunction · 0.50
warnMethod · 0.45

Tested by

no test coverage detected