mirror of
https://github.com/deepfakes/faceswap
synced 2025-06-09 04:36:50 -04:00
32 lines
997 B
Python
32 lines
997 B
Python
'''
|
|
Multiple plaidml implementation.
|
|
'''
|
|
|
|
import plaidml
|
|
|
|
|
|
def pad(data, paddings, mode="CONSTANT", name=None, constant_value=0):
|
|
""" PlaidML Pad """
|
|
# TODO: use / implement other padding method when required
|
|
# CONSTANT -> SpatialPadding ? | Doesn't support first and last axis +
|
|
# no support for constant_value
|
|
# SYMMETRIC -> Requires implement ?
|
|
if mode.upper() != "REFLECT":
|
|
raise NotImplementedError("pad only supports mode == 'REFLECT'")
|
|
if constant_value != 0:
|
|
raise NotImplementedError("pad does not support constant_value != 0")
|
|
return plaidml.op.reflection_padding(data, paddings)
|
|
|
|
|
|
def is_plaidml_error(error):
|
|
""" Test whether the given exception is a plaidml Exception.
|
|
|
|
error: :class:`Exception`
|
|
The generated error
|
|
|
|
Returns
|
|
-------
|
|
bool
|
|
``True`` if the given error has been generated from plaidML otherwise ``False``
|
|
"""
|
|
return isinstance(error, plaidml.exceptions.PlaidMLError)
|