Skip to content

Commit d4a78d4

Browse files
Lifannrhdong
authored andcommitted
Update API docs
1 parent ed04c3c commit d4a78d4

30 files changed

+7022
-81
lines changed

docs/api_docs/tfra/dynamic_embedding.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,32 @@ Export dynamic_embedding APIs.
2727

2828
## Modules
2929

30+
[`keras`](../tfra/dynamic_embedding/keras.md) module
31+
3032
[`math`](../tfra/dynamic_embedding/math.md) module: math operations.
3133

34+
[`shadow_ops`](../tfra/dynamic_embedding/shadow_ops.md) module: Dynamic Embedding is designed for Large-scale Sparse Weights Training.
35+
3236
## Classes
3337

3438
[`class CuckooHashTable`](../tfra/dynamic_embedding/CuckooHashTable.md): A generic mutable hash table implementation.
3539

40+
[`class CuckooHashTableConfig`](../tfra/dynamic_embedding/CuckooHashTableConfig.md)
41+
42+
[`class CuckooHashTableCreator`](../tfra/dynamic_embedding/CuckooHashTableCreator.md): A generic KV table creator.
43+
3644
[`class FrequencyRestrictPolicy`](../tfra/dynamic_embedding/FrequencyRestrictPolicy.md): A derived policy to eliminate features in variable follow the
3745

38-
[`class GraphKeys`](../tfra/dynamic_embedding/GraphKeys.md): Extended standard names related to `dynamic_embedding_ops.Variable` to use
46+
[`class GraphKeys`](../tfra/dynamic_embedding/GraphKeys.md): (Deprecated) extended standard names related to
3947

4048
[`class ModelMode`](../tfra/dynamic_embedding/ModelMode.md): The global config of model modes.
4149

50+
[`class RedisTable`](../tfra/dynamic_embedding/RedisTable.md): A generic mutable hash table implementation.
51+
52+
[`class RedisTableConfig`](../tfra/dynamic_embedding/RedisTableConfig.md): RedisTableConfig config json file for connecting Redis service and
53+
54+
[`class RedisTableCreator`](../tfra/dynamic_embedding/RedisTableCreator.md): RedisTableCreator will create a object to pass itself to the others classes
55+
4256
[`class RestrictPolicy`](../tfra/dynamic_embedding/RestrictPolicy.md): Base class of restrict policies. Never use this class directly, but
4357

4458
[`class TimestampRestrictPolicy`](../tfra/dynamic_embedding/TimestampRestrictPolicy.md): A derived policy to eliminate features in variable follow the

docs/api_docs/tfra/dynamic_embedding/CuckooHashTable.md

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
<meta itemprop="property" content="value_dtype"/>
88
<meta itemprop="property" content="__getitem__"/>
99
<meta itemprop="property" content="__init__"/>
10+
<meta itemprop="property" content="accum"/>
11+
<meta itemprop="property" content="clear"/>
1012
<meta itemprop="property" content="export"/>
1113
<meta itemprop="property" content="insert"/>
1214
<meta itemprop="property" content="lookup"/>
@@ -67,8 +69,9 @@ __init__(
6769
value_dtype,
6870
default_value,
6971
name='CuckooHashTable',
70-
checkpoint=True,
71-
init_size=0
72+
checkpoint=(True),
73+
init_size=0,
74+
config=None
7275
)
7376
```
7477

@@ -87,7 +90,7 @@ and value_dtype, respectively.
8790
* <b>`checkpoint`</b>: if True, the contents of the table are saved to and restored
8891
from checkpoints. If `shared_name` is empty for a checkpointed table, it
8992
is shared using the table node name.
90-
* <b>`init_size`</b>: initial size for the Variable and initial size of each hash
93+
* <b>`init_size`</b>: initial size for the Variable and initial size of each hash
9194
tables will be int(init_size / N), N is the number of the devices.
9295

9396

@@ -139,6 +142,68 @@ __getitem__(keys)
139142
Looks up `keys` in a table, outputs the corresponding values.
140143

141144

145+
<h3 id="accum"><code>accum</code></h3>
146+
147+
<a target="_blank" href="https://github.com/tensorflow/recommenders-addons/tree/master/tensorflow_recommenders_addons/dynamic_embedding/python/ops/cuckoo_hashtable_ops.py">View source</a>
148+
149+
``` python
150+
accum(
151+
keys,
152+
values_or_deltas,
153+
exists,
154+
name=None
155+
)
156+
```
157+
158+
Associates `keys` with `values`.
159+
160+
161+
#### Args:
162+
163+
164+
* <b>`keys`</b>: Keys to accmulate. Can be a tensor of any shape.
165+
Must match the table's key type.
166+
* <b>`values_or_deltas`</b>: values to be associated with keys. Must be a tensor of
167+
the same shape as `keys` and match the table's value type.
168+
* <b>`exists`</b>: A bool type tensor indicates if keys already exist or not.
169+
Must be a tensor of the same shape as `keys`.
170+
* <b>`name`</b>: A name for the operation (optional).
171+
172+
173+
#### Returns:
174+
175+
The created Operation.
176+
177+
178+
179+
#### Raises:
180+
181+
182+
* <b>`TypeError`</b>: when `keys` or `values` doesn't match the table data
183+
types.
184+
185+
<h3 id="clear"><code>clear</code></h3>
186+
187+
<a target="_blank" href="https://github.com/tensorflow/recommenders-addons/tree/master/tensorflow_recommenders_addons/dynamic_embedding/python/ops/cuckoo_hashtable_ops.py">View source</a>
188+
189+
``` python
190+
clear(name=None)
191+
```
192+
193+
clear all keys and values in the table.
194+
195+
196+
#### Args:
197+
198+
199+
* <b>`name`</b>: A name for the operation (optional).
200+
201+
202+
#### Returns:
203+
204+
The created Operation.
205+
206+
142207
<h3 id="export"><code>export</code></h3>
143208

144209
<a target="_blank" href="https://github.com/tensorflow/recommenders-addons/tree/master/tensorflow_recommenders_addons/dynamic_embedding/python/ops/cuckoo_hashtable_ops.py">View source</a>
@@ -207,6 +272,7 @@ The created Operation.
207272
lookup(
208273
keys,
209274
dynamic_default_values=None,
275+
return_exists=(False),
210276
name=None
211277
)
212278
```
@@ -223,6 +289,8 @@ The `default_value` is used for keys not present in the table.
223289
* <b>`dynamic_default_values`</b>: The values to use if a key is missing in the
224290
table. If None (by default), the static default_value
225291
`self._default_value` will be used.
292+
* <b>`return_exists`</b>: if True, will return a additional Tensor which indicates
293+
if or not keys are existing in the table.
226294
* <b>`name`</b>: A name for the operation (optional).
227295

228296

@@ -231,6 +299,9 @@ The `default_value` is used for keys not present in the table.
231299
A tensor containing the values in the same shape as `keys` using the
232300
table's value type.
233301

302+
* <b>`exists`</b>: A bool type Tensor of the same shape as `keys` which indicates
303+
if keys are existing in the table.
304+
Only provided if `return_exists` is True.
234305

235306

236307
#### Raises:
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<div itemscope itemtype="http://developers.google.com/ReferenceObject">
2+
<meta itemprop="name" content="tfra.dynamic_embedding.CuckooHashTableConfig" />
3+
<meta itemprop="path" content="Stable" />
4+
<meta itemprop="property" content="__init__"/>
5+
</div>
6+
7+
# tfra.dynamic_embedding.CuckooHashTableConfig
8+
9+
<!-- Insert buttons and diff -->
10+
11+
<table class="tfo-notebook-buttons tfo-api" align="left">
12+
13+
<td>
14+
<a target="_blank" href="https://github.com/tensorflow/recommenders-addons/tree/master/tensorflow_recommenders_addons/dynamic_embedding/python/ops/dynamic_embedding_creator.py">
15+
<img src="https://www.tensorflow.org/images/GitHub-Mark-32px.png" />
16+
View source on GitHub
17+
</a>
18+
</td></table>
19+
<br/>
20+
<br/>
21+
<br/>
22+
<br/>
23+
24+
25+
26+
## Class `CuckooHashTableConfig`
27+
28+
29+
30+
31+
32+
<!-- Placeholder for "Used in" -->
33+
34+
35+
<h2 id="__init__"><code>__init__</code></h2>
36+
37+
<a target="_blank" href="https://github.com/tensorflow/recommenders-addons/tree/master/tensorflow_recommenders_addons/dynamic_embedding/python/ops/dynamic_embedding_creator.py">View source</a>
38+
39+
``` python
40+
__init__()
41+
```
42+
43+
CuckooHashTableConfig include nothing for parameter default satisfied.
44+
45+
46+
47+
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<div itemscope itemtype="http://developers.google.com/ReferenceObject">
2+
<meta itemprop="name" content="tfra.dynamic_embedding.CuckooHashTableCreator" />
3+
<meta itemprop="path" content="Stable" />
4+
<meta itemprop="property" content="__init__"/>
5+
<meta itemprop="property" content="create"/>
6+
<meta itemprop="property" content="get_config"/>
7+
</div>
8+
9+
# tfra.dynamic_embedding.CuckooHashTableCreator
10+
11+
<!-- Insert buttons and diff -->
12+
13+
<table class="tfo-notebook-buttons tfo-api" align="left">
14+
15+
<td>
16+
<a target="_blank" href="https://github.com/tensorflow/recommenders-addons/tree/master/tensorflow_recommenders_addons/dynamic_embedding/python/ops/dynamic_embedding_creator.py">
17+
<img src="https://www.tensorflow.org/images/GitHub-Mark-32px.png" />
18+
View source on GitHub
19+
</a>
20+
</td></table>
21+
<br/>
22+
<br/>
23+
<br/>
24+
<br/>
25+
26+
27+
28+
## Class `CuckooHashTableCreator`
29+
30+
A generic KV table creator.
31+
32+
33+
34+
<!-- Placeholder for "Used in" -->
35+
36+
KV table instance will be created by the create function with config.
37+
And also a config class for specific table instance backend should be
38+
inited before callling the creator function.
39+
And then, the KVCreator class instance will be passed to the Variable
40+
class for creating the real KV table backend(TF resource).
41+
42+
#### Example usage:
43+
44+
45+
46+
```python
47+
redis_config1=tfra.dynamic_embedding.RedisTableConfig(
48+
redis_config_abs_dir="xx/yy.json"
49+
)
50+
redis_creator1=tfra.dynamic_embedding.RedisTableCreator(redis_config1)
51+
```
52+
53+
<h2 id="__init__"><code>__init__</code></h2>
54+
55+
<a target="_blank" href="https://github.com/tensorflow/recommenders-addons/tree/master/tensorflow_recommenders_addons/dynamic_embedding/python/ops/dynamic_embedding_creator.py">View source</a>
56+
57+
``` python
58+
__init__(config=None)
59+
```
60+
61+
Initialize self. See help(type(self)) for accurate signature.
62+
63+
64+
65+
66+
## Methods
67+
68+
<h3 id="create"><code>create</code></h3>
69+
70+
<a target="_blank" href="https://github.com/tensorflow/recommenders-addons/tree/master/tensorflow_recommenders_addons/dynamic_embedding/python/ops/dynamic_embedding_creator.py">View source</a>
71+
72+
``` python
73+
create(
74+
key_dtype=None,
75+
value_dtype=None,
76+
default_value=None,
77+
name=None,
78+
checkpoint=None,
79+
init_size=None,
80+
config=None
81+
)
82+
```
83+
84+
85+
86+
87+
<h3 id="get_config"><code>get_config</code></h3>
88+
89+
<a target="_blank" href="https://github.com/tensorflow/recommenders-addons/tree/master/tensorflow_recommenders_addons/dynamic_embedding/python/ops/dynamic_embedding_creator.py">View source</a>
90+
91+
``` python
92+
get_config()
93+
```
94+
95+
96+
97+
98+
99+

docs/api_docs/tfra/dynamic_embedding/DynamicEmbeddingOptimizer.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
An optimizer wrapper to make any TensorFlow optimizer capable of training
2626

2727
``` python
28-
tfra.dynamic_embedding.DynamicEmbeddingOptimizer()
28+
tfra.dynamic_embedding.DynamicEmbeddingOptimizer(
29+
bp_v2=(False),
30+
synchronous=(False)
31+
)
2932
```
3033

3134

@@ -37,6 +40,11 @@ Dynamic Embeddding Variables.
3740

3841

3942
* <b>`self`</b>: a TensorFlow optimizer.
43+
* <b>`bp_v2`</b>: If True, updating parameters will use updating instead of setting, which solves
44+
the race condition problem among workers during back-propagation in large-scale
45+
distributed asynchronous training. Reference: https://www.usenix.org/system/files/osdi20-jiang.pdf
46+
* <b>`synchronous`</b>: If True, we will use horovod's all-reduce method to merge the dense grad of model parameter,
47+
the default reduce method is SUM. For TrainableWrapper's grad, keep same with before.
4048

4149

4250
#### Example usage:

docs/api_docs/tfra/dynamic_embedding/GraphKeys.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@
2626

2727
## Class `GraphKeys`
2828

29-
Extended standard names related to `dynamic_embedding_ops.Variable` to use
29+
(Deprecated) extended standard names related to
3030

3131

3232

3333
<!-- Placeholder for "Used in" -->
34-
for graph collections.
35-
34+
`dynamic_embedding_ops.Variable` to use for graph collections.
3635
The following standard keys are defined:
37-
3836
* `DYNAMIC_EMBEDDING_VARIABLES`: the default collection of
3937
all `dynamic_embedding_ops.Variable` objects.
4038
* `TRAINABLE_DYNAMIC_EMBEDDING_VARIABLES`: the subset of

0 commit comments

Comments
 (0)