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

Method _compile

python/paddle/base/compiler.py:326–362  ·  view source on GitHub ↗

Compile the program based on the configs. Args: scope: The variables (resources) that are associated with this compiled program. place: The location that the compiled program will be run on. Returns: self

(self, scope, place)

Source from the content-addressed store, hash-verified

324 return core.create_paddle_predictor(self._infer_config)
325
326 def _compile(self, scope, place):
327 """Compile the program based on the configs.
328
329 Args:
330 scope: The variables (resources) that are associated with
331 this compiled program.
332 place: The location that the compiled program will be run on.
333
334 Returns:
335 self
336 """
337 if self._compiled:
338 if scope and self._scope != scope:
339 raise ValueError("Cannot compile program with different scope.")
340 if place and not self._place._equals(place):
341 raise ValueError("Cannot compile program with different place.")
342 return self
343 self._compiled = True
344
345 self._scope = scope
346 self._place = place
347
348 if self._is_inference:
349 self._executor = self._compile_inference()
350 else:
351 self._places = [self._place]
352
353 if isinstance(self._place, core.CUDAPlace):
354 use_device = DeviceType.CUDA
355 elif isinstance(self._place, core.XPUPlace):
356 use_device = DeviceType.XPU
357 else:
358 use_device = DeviceType.CPU
359 self._executor = self._compile_data_parallel(
360 use_device=use_device, scope=self._scope, places=self._places
361 )
362 return self
363
364 def _get_places(self, place, place_list):
365 has_set_place = place_list is not None

Callers 4

add_build_strategy_forFunction · 0.95
_run_implMethod · 0.80

Calls 3

_compile_inferenceMethod · 0.95
ValueErrorClass · 0.85

Tested by

no test coverage detected