Python tensorflow.python.platform.resource_loader.get_path_to_datafile() Examples
The following are 21
code examples of tensorflow.python.platform.resource_loader.get_path_to_datafile().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tensorflow.python.platform.resource_loader
, or try the search function
.
Example #1
Source File: ffmpeg_ops.py From keras-lambda with MIT License | 6 votes |
def _load_library(name, op_list=None): """Loads a .so file containing the specified operators. Args: name: The name of the .so file to load. op_list: A list of names of operators that the library should have. If None then the .so file's contents will not be verified. Raises: NameError if one of the required ops is missing. """ try: filename = resource_loader.get_path_to_datafile(name) library = load_library.load_op_library(filename) for expected_op in (op_list or []): for lib_op in library.OP_LIST.op: if lib_op.name == expected_op: break else: raise NameError('Could not find operator %s in dynamic library %s' % (expected_op, name)) except errors.NotFoundError: logging.warning('%s file could not be loaded.', name)
Example #2
Source File: loader.py From keras-lambda with MIT License | 6 votes |
def load_op_library(path): """Loads a contrib op library from the given path. NOTE(mrry): On Windows, we currently assume that contrib op libraries are statically linked into the main TensorFlow Python extension DLL. Args: path: An absolute path to a shared object file. Returns: A Python module containing the Python wrappers for Ops defined in the plugin. """ if os.name != 'nt': path = resource_loader.get_path_to_datafile(path) ret = load_library.load_op_library(path) assert ret, 'Could not load %s' % path return ret else: # NOTE(mrry): return None
Example #3
Source File: loader.py From auto-alt-text-lambda-api with MIT License | 6 votes |
def load_op_library(path): """Loads a contrib op library from the given path. NOTE(mrry): On Windows, we currently assume that contrib op libraries are statically linked into the main TensorFlow Python extension DLL. Args: path: An absolute path to a shared object file. Returns: A Python module containing the Python wrappers for Ops defined in the plugin. """ if os.name != 'nt': path = resource_loader.get_path_to_datafile(path) ret = load_library.load_op_library(path) assert ret, 'Could not load %s' % path return ret else: # NOTE(mrry): return None
Example #4
Source File: ffmpeg_ops.py From auto-alt-text-lambda-api with MIT License | 6 votes |
def _load_library(name, op_list=None): """Loads a .so file containing the specified operators. Args: name: The name of the .so file to load. op_list: A list of names of operators that the library should have. If None then the .so file's contents will not be verified. Raises: NameError if one of the required ops is missing. """ try: filename = resource_loader.get_path_to_datafile(name) library = load_library.load_op_library(filename) for expected_op in (op_list or []): for lib_op in library.OP_LIST.op: if lib_op.name == expected_op: break else: raise NameError('Could not find operator %s in dynamic library %s' % (expected_op, name)) except errors.NotFoundError: logging.warning('%s file could not be loaded.', name)
Example #5
Source File: mpi_ops.py From training_results_v0.6 with Apache License 2.0 | 6 votes |
def _load_library(name, op_list=None): """Loads a .so file containing the specified operators. Args: name: The name of the .so file to load. op_list: A list of names of operators that the library should have. If None then the .so file's contents will not be verified. Raises: NameError if one of the required ops is missing. NotFoundError if were not able to load .so file. """ filename = resource_loader.get_path_to_datafile(name) library = load_library.load_op_library(filename) for expected_op in (op_list or []): for lib_op in library.OP_LIST.op: if lib_op.name == expected_op: break else: raise NameError( 'Could not find operator %s in dynamic library %s' % (expected_op, name)) return library
Example #6
Source File: loader.py From deep_image_model with Apache License 2.0 | 6 votes |
def load_op_library(path): """Loads a contrib op library from the given path. NOTE(mrry): On Windows, we currently assume that contrib op libraries are statically linked into the main TensorFlow Python extension DLL. Args: path: An absolute path to a shared object file. Returns: A Python module containing the Python wrappers for Ops defined in the plugin. """ if os.name != 'nt': path = resource_loader.get_path_to_datafile(path) ret = load_library.load_op_library(path) assert ret, 'Could not load %s' % path return ret else: # NOTE(mrry): return None
Example #7
Source File: inference_ops.py From deep_image_model with Apache License 2.0 | 5 votes |
def Load(): """Load the inference ops library and return the loaded module.""" with _ops_lock: global _inference_ops if not _inference_ops: ops_path = resource_loader.get_path_to_datafile(INFERENCE_OPS_FILE) logging.info('data path: %s', ops_path) _inference_ops = load_library.load_op_library(ops_path) assert _inference_ops, 'Could not load inference_ops.so' return _inference_ops
Example #8
Source File: variables.py From keras-lambda with MIT License | 5 votes |
def zero_initializer(ref, use_locking=True, name="zero_initializer"): """Initialize 'ref' with all zeros, ref tensor should be uninitialized. If already initialized, you will get ValueError. This op is intended to save memory during initialization. Args: ref: ref of the tensor need to be zero initialized. name: optional name for this operation. Returns: ref that initialized. Raises: ValueError: If ref tensor is initialized. """ loader.load_op_library( resource_loader.get_path_to_datafile("_variable_ops.so")) return gen_variable_ops.zero_initializer(ref, name=name)
Example #9
Source File: training_ops.py From keras-lambda with MIT License | 5 votes |
def Load(): """Load training ops library and return the loaded module.""" with _ops_lock: global _training_ops if not _training_ops: ops_path = resource_loader.get_path_to_datafile(TRAINING_OPS_FILE) logging.info('data path: %s', ops_path) _training_ops = load_library.load_op_library(ops_path) assert _training_ops, 'Could not load _training_ops.so' return _training_ops
Example #10
Source File: kmeans_labeler_request_handler.py From moonlight with Apache License 2.0 | 5 votes |
def do_GET(self): template_path = resource_loader.get_path_to_datafile( 'kmeans_labeler_template.html') template = mako_template.Template(open(template_path).read()) page = create_page(self.clusters, template) self.send_response(http_client.OK) self.send_header('Content-Type', 'text/html; charset=utf-8') self.end_headers() self.wfile.write(page)
Example #11
Source File: kmeans_labeler_request_handler_test.py From moonlight with Apache License 2.0 | 5 votes |
def testCreatePage(self): num_clusters = 10 clusters = np.random.random((num_clusters, 12, 14)) template_src = resource_loader.get_path_to_datafile( 'kmeans_labeler_template.html') template = mako_template.Template(open(template_src).read()) html = kmeans_labeler_request_handler.create_page(clusters, template) self.assertEqual(len(re.findall('<img', html)), num_clusters) self.assertEqual(len(re.findall('<select', html)), num_clusters)
Example #12
Source File: ext_utils.py From nvtx-plugins with Apache License 2.0 | 5 votes |
def load_library(name): """Loads a .so file containing the specified operators. Args: name: The name of the .so file to load. Raises: NotFoundError if were not able to load .so file. """ filename = resource_loader.get_path_to_datafile(name) library = _load_library.load_op_library(filename) return library
Example #13
Source File: variables.py From deep_image_model with Apache License 2.0 | 5 votes |
def zero_initializer(ref, use_locking=True, name="zero_initializer"): """Initialize 'ref' with all zeros, ref tensor should be uninitialized. If already initialized, you will get ValueError. This op is intended to save memory during initialization. Args: ref: ref of the tensor need to be zero initialized. name: optional name for this operation. Returns: ref that initialized. Raises: ValueError: If ref tensor is initialized. """ loader.load_op_library( resource_loader.get_path_to_datafile("_variable_ops.so")) return gen_variable_ops.zero_initializer(ref, name=name)
Example #14
Source File: training_ops.py From deep_image_model with Apache License 2.0 | 5 votes |
def Load(): """Load training ops library and return the loaded module.""" with _ops_lock: global _training_ops if not _training_ops: ops_path = resource_loader.get_path_to_datafile(TRAINING_OPS_FILE) logging.info('data path: %s', ops_path) _training_ops = load_library.load_op_library(ops_path) assert _training_ops, 'Could not load _training_ops.so' return _training_ops
Example #15
Source File: training_ops.py From lambda-packs with MIT License | 5 votes |
def Load(): """Load training ops library and return the loaded module.""" with _ops_lock: global _training_ops if not _training_ops: ops_path = resource_loader.get_path_to_datafile(TRAINING_OPS_FILE) logging.info('data path: %s', ops_path) _training_ops = loader.load_op_library(ops_path) assert _training_ops, 'Could not load _training_ops.so' return _training_ops
Example #16
Source File: data_ops.py From deep_image_model with Apache License 2.0 | 5 votes |
def Load(): """Load the data ops library and return the loaded module.""" with _ops_lock: global _data_ops if not _data_ops: ops_path = resource_loader.get_path_to_datafile(DATA_OPS_FILE) logging.info('data path: %s', ops_path) _data_ops = load_library.load_op_library(ops_path) assert _data_ops, 'Could not load _data_ops.so' return _data_ops
Example #17
Source File: training_ops.py From deep_image_model with Apache License 2.0 | 5 votes |
def Load(): """Load training ops library and return the loaded module.""" with _ops_lock: global _training_ops if not _training_ops: ops_path = resource_loader.get_path_to_datafile(TRAINING_OPS_FILE) logging.info('data path: %s', ops_path) _training_ops = load_library.load_op_library(ops_path) assert _training_ops, 'Could not load _training_ops.so' return _training_ops
Example #18
Source File: variables.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def zero_initializer(ref, use_locking=True, name="zero_initializer"): """Initialize 'ref' with all zeros, ref tensor should be uninitialized. If already initialized, you will get ValueError. This op is intended to save memory during initialization. Args: ref: ref of the tensor need to be zero initialized. name: optional name for this operation. Returns: ref that initialized. Raises: ValueError: If ref tensor is initialized. """ loader.load_op_library( resource_loader.get_path_to_datafile("_variable_ops.so")) return gen_variable_ops.zero_initializer(ref, name=name)
Example #19
Source File: training_ops.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def Load(): """Load training ops library and return the loaded module.""" with _ops_lock: global _training_ops if not _training_ops: ops_path = resource_loader.get_path_to_datafile(TRAINING_OPS_FILE) logging.info('data path: %s', ops_path) _training_ops = load_library.load_op_library(ops_path) assert _training_ops, 'Could not load _training_ops.so' return _training_ops
Example #20
Source File: variables.py From lambda-packs with MIT License | 5 votes |
def zero_initializer(ref, use_locking=True, name="zero_initializer"): """Initialize 'ref' with all zeros, ref tensor should be uninitialized. If already initialized, you will get ValueError. This op is intended to save memory during initialization. Args: ref: ref of the tensor need to be zero initialized. name: optional name for this operation. Returns: ref that initialized. Raises: ValueError: If ref tensor is initialized. """ loader.load_op_library( resource_loader.get_path_to_datafile("_variable_ops.so")) return gen_variable_ops.zero_initializer(ref, name=name)
Example #21
Source File: loader.py From lambda-packs with MIT License | 5 votes |
def load_op_library(path): """Loads a contrib op library from the given path. NOTE(mrry): On Windows, we currently assume that some contrib op libraries are statically linked into the main TensorFlow Python extension DLL - use dynamically linked ops if the .so is present. Args: path: An absolute path to a shared object file. Returns: A Python module containing the Python wrappers for Ops defined in the plugin. """ if os.name == 'nt': # To avoid makeing every user_ops aware of windows, re-write # the file extension from .so to .dll. path = re.sub(r'\.so$', '.dll', path) # Currently we have only some user_ops as dlls on windows - don't try # to load them if the dll is not found. # TODO(mrry): Once we have all of them this check should be removed. if not os.path.exists(path): return None path = resource_loader.get_path_to_datafile(path) ret = load_library.load_op_library(path) assert ret, 'Could not load %s' % path return ret