def compileAndExport(self, filename) -> None: """Compiles the graph and exports it to the specified file. This will form the snap::Graph and compile the polar::Executable before exporting the executable and metadata. Arguments: filename: Where to save the executable and metadata. If it does not exist, it will be created. Raises: popart.OutOfMemoryException: If an out of memory event occurs OSError: Thrown in the event of any file system related errors during the export """ filename = os.path.expanduser(filename) if os.path.isdir(filename): makedirsAndCheckWritable(filename) else: makedirsAndCheckWritable(os.path.dirname(filename)) err = popart.OutOfMemoryError() super(TrainingSession, self).compileAndExport(filename, err) if not err.isSuccessful(): raise popart.OutOfMemoryException(err)
def prepareDevice(self): err = popart.OutOfMemoryError() super(InferenceSession, self).prepareDevice(err) # If an error occurred during the perpareDevice raise an exception if not err.isSuccessful(): raise popart.OutOfMemoryException(err)
def prepareDevice(self) -> None: """Prepare the network for execution. This will create the ``poplar::Graph`` and ``poplar::Engine``, and set up ``poplar::Streams``. Raises: popart.OutOfMemoryException: If an out of memory event occurs """ err = popart.OutOfMemoryError() super(TrainingSession, self).prepareDevice(err) if not err.isSuccessful(): raise popart.OutOfMemoryException(err)
def prepareDevice(self, loadEngine: bool = True) -> None: """Prepare the network for execution. This will create the ``snap::Graph`` and ``poplar::Engine``, and set up ``poplar::Streams``. Arguments: loadEngine: Load the engine and connect the streams once the device is ready. Raises: popart.OutOfMemoryException: If an out of memory event occurs """ err = popart.OutOfMemoryError() super(TrainingSession, self).prepareDevice(loadEngine, err) if not err.isSuccessful(): raise popart.OutOfMemoryException(err)
def compileAndExport(self, executablePath=None, weightsPath=None) -> None: """Compiles the graph and exports it to the specified paths. This will form the poplar::Graph and compile the polar::Executable before exporting the executable and metadata to allow offline running. Arguments: executablePath: The path to export the executable and metadata. If it does not exist, it will be created. If empty, the executable is not exported. weightsPath: The path to export the weights. If it does not exist, it will be created. If empty, the weights are not exported. not exported Raises: popart.OutOfMemoryException: If an out of memory event occurs OSError: Thrown in the event of any file system related errors during the export """ if executablePath: executablePath = os.path.expanduser(executablePath) makedirsAndCheckWritable(executablePath) else: executablePath = "" if weightsPath: weightsPath = os.path.expanduser(weightsPath) makedirsAndCheckWritable(weightsPath) else: weightsPath = "" err = popart.OutOfMemoryError() super(TrainingSession, self).compileAndExport(executablePath, weightsPath, err) if not err.isSuccessful(): raise popart.OutOfMemoryException(err)
def prepareDevice(self): err = popart.OutOfMemoryError() super(TrainingSession, self).prepareDevice(err) if not err.isSuccessful(): raise popart.OutOfMemoryException(err)