def testDeserializeInvalidVariant(self): mu = gen_resource_variable_ops.mutex_v2() mu_lock = gen_resource_variable_ops.mutex_lock(mutex=mu) @def_function.function def f(): return sparse_ops.deserialize_sparse( serialized_sparse=mu_lock, dtype=dtypes.int32) with self.assertRaisesRegex(ValueError, r"Shape must be at least rank 1"): f()
def _init_from_args(self, name, shared_name): # pylint: disable=invalid-name """Initialize the CriticalSection from constructor arguments.""" with ops.name_scope(name, "CriticalSection", []) as name: with ops.init_scope(): # pylint: disable=protected-access container = ops.get_default_graph()._container # pylint: enable=protected-access if shared_name is None: shared_name = name if container is None: container = "" self._handle = gen_resource_variable_ops.mutex_v2( shared_name=shared_name, container=container, name=name) if not context.executing_eagerly(): ops.add_to_collections(CRITICAL_SECTIONS, self)
def _init_from_args(self, name, shared_name): # pylint: disable=invalid-name """Initialize the CriticalSection from constructor arguments.""" with ops.name_scope(name, "CriticalSection", []) as name: with ops.init_scope(): # pylint: disable=protected-access container = ops.get_default_graph()._container # pylint: enable=protected-access if shared_name is None: shared_name = name if container is None: container = "" self._handle = gen_resource_variable_ops.mutex_v2( shared_name=shared_name, container=container, name=name) # Get a uniquely identifying signature for the handle. self._signature = ( container, # If shared_name is empty, a unique CriticalSection is created. shared_name or id(self._handle), _get_device_or_colocation(self._handle)) if not context.executing_eagerly(): ops.add_to_collections(CRITICAL_SECTIONS, self)