Default variable creator.
(next_creator=None, **kwargs)
| 3289 | |
| 3290 | |
| 3291 | def default_variable_creator(next_creator=None, **kwargs): |
| 3292 | """Default variable creator.""" |
| 3293 | assert next_creator is None |
| 3294 | initial_value = kwargs.get("initial_value", None) |
| 3295 | trainable = kwargs.get("trainable", None) |
| 3296 | collections = kwargs.get("collections", None) |
| 3297 | validate_shape = kwargs.get("validate_shape", True) |
| 3298 | caching_device = kwargs.get("caching_device", None) |
| 3299 | name = kwargs.get("name", None) |
| 3300 | variable_def = kwargs.get("variable_def", None) |
| 3301 | dtype = kwargs.get("dtype", None) |
| 3302 | embedding_block_num=kwargs.get("embedding_block_num", None), |
| 3303 | expected_shape = kwargs.get("expected_shape", None) |
| 3304 | import_scope = kwargs.get("import_scope", None) |
| 3305 | constraint = kwargs.get("constraint", None) |
| 3306 | use_resource = kwargs.get("use_resource", None) |
| 3307 | synchronization = kwargs.get("synchronization", None) |
| 3308 | aggregation = kwargs.get("aggregation", None) |
| 3309 | shape = kwargs.get("shape", None) |
| 3310 | invalid_key = kwargs.get("invalid_key", None) |
| 3311 | evconfig = kwargs.get("evconfig", None) |
| 3312 | initializer = kwargs.get("embedding_initializer", None) |
| 3313 | ht_partition_num = kwargs.get("ht_partition_num", None) |
| 3314 | |
| 3315 | if use_resource is None: |
| 3316 | use_resource = get_variable_scope().use_resource |
| 3317 | if use_resource is None: |
| 3318 | use_resource = _DEFAULT_USE_RESOURCE |
| 3319 | use_resource = use_resource or context.executing_eagerly() |
| 3320 | if use_resource and invalid_key is None: |
| 3321 | distribute_strategy = kwargs.get("distribute_strategy", None) |
| 3322 | return resource_variable_ops.ResourceVariable( |
| 3323 | initial_value=initial_value, |
| 3324 | trainable=trainable, |
| 3325 | collections=collections, |
| 3326 | validate_shape=validate_shape, |
| 3327 | caching_device=caching_device, |
| 3328 | name=name, |
| 3329 | dtype=dtype, |
| 3330 | constraint=constraint, |
| 3331 | variable_def=variable_def, |
| 3332 | import_scope=import_scope, |
| 3333 | distribute_strategy=distribute_strategy, |
| 3334 | synchronization=synchronization, |
| 3335 | aggregation=aggregation, |
| 3336 | shape=shape) |
| 3337 | elif use_resource and invalid_key is not None: |
| 3338 | emb_blocknum = embedding_block_num[0] |
| 3339 | if emb_blocknum is None: |
| 3340 | ev = kv_variable_ops.EmbeddingVariable( |
| 3341 | initial_value=initial_value, trainable=trainable, |
| 3342 | collections=collections, validate_shape=validate_shape, |
| 3343 | caching_device=caching_device, name=name, dtype=dtype, |
| 3344 | constraint=constraint, variable_def=variable_def, |
| 3345 | import_scope=import_scope, invalid_key=invalid_key, |
| 3346 | evconfig=evconfig, |
| 3347 | initializer=initializer, ht_partition_num=ht_partition_num) |
| 3348 | if evconfig.init_data_source is not None: |
nothing calls this directly
no test coverage detected