def load_oplib(lib_name):
"""
Load TensorFlow operator library.
"""
# use absolute path so that ops.py can be called from other directory
lib_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'lib{0}.so'.format(lib_name))
# duplicate library with a random new name so that
# a running program will not be interrupted when the original library is updated
lib_copy_path = '/tmp/lib{0}_{1}.so'.format(str(uuid.uuid4())[:8], LIB_NAME)
shutil.copyfile(lib_path, lib_copy_path)
oplib = tf.load_op_library(lib_copy_path)
return oplib
评论列表
文章目录