Skip to content

Commit ce1b182

Browse files
committed
Resolve conflicts
2 parents 5feb26c + 0441e55 commit ce1b182

15 files changed

+68
-46
lines changed

.github/workflows/ci_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
- master
1111
- r*
1212
env:
13-
USE_BAZEL_VERSION: "3.7.2"
13+
USE_BAZEL_VERSION: "5.1.1"
1414

1515
jobs:
1616
yapf-test:

.github/workflows/release.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ on:
1717
env:
1818
MIN_PY_VERSION: '3.7'
1919
MAX_PY_VERSION: '3.9'
20-
USE_BAZEL_VERSION: "3.7.2"
20+
USE_BAZEL_VERSION: "5.1.1"
2121
HOROVOD_VERSION: '0.23.0'
2222

2323
jobs:
@@ -168,11 +168,15 @@ jobs:
168168
name: Upload dev container to DockerHub
169169
needs: [release-wheel, test-with-bazel]
170170
runs-on: ubuntu-18.04
171+
strategy:
172+
matrix:
173+
py-version: ['3.7', '3.8', '3.9']
171174
if: (github.event_name == 'push' && github.ref == 'refs/heads/master')
172175
steps:
173176
- uses: actions/checkout@v2
174177
- run: |
175178
set -e -x
176179
echo ${{ secrets.DOCKER_PW }} | docker login --username ${{ secrets.DOCKER_USER }} --password-stdin
180+
export PY_VERSION=${{ matrix.py-version }}
177181
bash .github/workflows/github_build_dev_container.sh
178-
docker push tfra/dev_container:latest-cpu
182+
docker push tfra/dev_container:latest-python${{ matrix.py-version }}

README.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,15 @@ but maybe this doc can help you : [Extract headers from TensorFlow compiling dir
134134
At the same time, we find some OPs used by TRFA have better performance, so we highly recommend you update TensorFlow to 2.x.
135135

136136
#### Installing from Source
137+
138+
For all developers, we recommend you use the development docker containers which are all GPU enabled:
139+
```shell
140+
docker pull tfra/dev_container:latest-python3.8 # "3.7", "3.9" are all avaliable.
141+
docker run --privileged --gpus all -it --rm -v $(pwd):$(pwd) tfra/dev_container:latest-3.8
142+
```
143+
137144
##### CPU Only
138-
You can also install from source. This requires the [Bazel](https://bazel.build/) build system (version == 3.7.2).
145+
You can also install from source. This requires the [Bazel](https://bazel.build/) build system (version == 5.1.1).
139146
Please install a TensorFlow on your compiling machine, The compiler needs to know the version of Tensorflow and
140147
its headers according to the installed TensorFlow.
141148

@@ -158,18 +165,20 @@ pip install artifacts/tensorflow_recommenders_addons-*.whl
158165
##### GPU Support
159166
Only `TF_NEED_CUDA=1` is required and other environment variables are optional:
160167
```shell
161-
PY_VERSION="3.7" \
162-
TF_NEED_CUDA=1 \
163-
TF_CUDA_VERSION=11.2 \
164-
TF_CUDNN_VERSION=8.1 \
165-
CUDA_TOOLKIT_PATH="/usr/local/cuda" \
166-
CUDNN_INSTALL_PATH="/usr/lib/x86_64-linux-gnu" \
168+
export TF_VERSION="2.5.1" # "2.7.0", "2.5.1" are well tested.
169+
export PY_VERSION="3.8"
170+
export TF_NEED_CUDA=1
171+
export TF_CUDA_VERSION=11.2
172+
export TF_CUDNN_VERSION=8.1
173+
export CUDA_TOOLKIT_PATH="/usr/local/cuda"
174+
export CUDNN_INSTALL_PATH="/usr/lib/x86_64-linux-gnu"
175+
167176
python configure.py
168177
```
169178
And then build the pip package and install:
170179
```shell
171180
bazel build --enable_runfiles build_pip_pkg
172-
TF_NEED_CUDA=1 bazel-bin/build_pip_pkg artifacts
181+
bazel-bin/build_pip_pkg artifacts
173182
pip install artifacts/tensorflow_recommenders_addons_gpu-*.whl
174183
```
175184
##### Apple Silicon Support (Beta Release)

configure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ def _VALID_BAZEL_VERSION(tf_version):
4040
'refering to the previous COMMIT to compile properly by themselves.')
4141
return target_bazel
4242
elif tf_version >= "2.0.0":
43-
target_bazel = "3.7.2"
43+
target_bazel = "5.1.1"
4444
logging.info(
4545
'To ensure code compatibility with Bazel rules_foreign_cc component, '
46-
'we specify Bazel version greater than 3.7.2 '
46+
'we specify Bazel version greater than 5.1.1 '
4747
'for Tensorflow versions greater than 2.0.0.')
4848
return target_bazel
4949
else:

tensorflow_recommenders_addons/dynamic_embedding/core/kernels/cuckoo_hashtable_op_gpu.cu.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ class CuckooHashTableOfTensorsGpu final : public LookupInterface {
115115
const Tensor& default_value) override {
116116
size_t len = d_keys.flat<K>().size();
117117
bool* d_status;
118-
gpu::ValueArrayBase<V>* d_default_value;
119118

120119
auto value_flat = value->flat_inner_dims<V, 2>();
121120
const auto default_flat = default_value.flat<V>();
@@ -140,7 +139,6 @@ class CuckooHashTableOfTensorsGpu final : public LookupInterface {
140139
CUDA_CHECK(cudaStreamSynchronize(_stream));
141140
}
142141
CUDA_CHECK(cudaFree(d_status));
143-
CUDA_CHECK(cudaFree(d_default_value));
144142
CUDA_CHECK(cudaStreamDestroy(_stream));
145143
}
146144
return Status::OK();
@@ -150,7 +148,6 @@ class CuckooHashTableOfTensorsGpu final : public LookupInterface {
150148
Tensor* value, const Tensor& default_value,
151149
Tensor* exists) {
152150
size_t len = d_keys.flat<K>().size();
153-
gpu::ValueArrayBase<V>* d_default_value;
154151

155152
auto value_flat = value->flat_inner_dims<V, 2>();
156153
const auto default_flat = default_value.flat<V>();
@@ -173,7 +170,6 @@ class CuckooHashTableOfTensorsGpu final : public LookupInterface {
173170
_stream, is_full_default);
174171
CUDA_CHECK(cudaStreamSynchronize(_stream));
175172
}
176-
CUDA_CHECK(cudaFree(d_default_value));
177173
CUDA_CHECK(cudaStreamDestroy(_stream));
178174
}
179175
return Status::OK();

tensorflow_recommenders_addons/dynamic_embedding/core/kernels/lookup_impl/lookup_table_op_cpu.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,21 @@ class TableWrapperBase {
116116
public:
117117
virtual ~TableWrapperBase() {}
118118
virtual bool insert_or_assign(K key, ConstTensor2D<V>& value_flat,
119-
int64 value_dim, int64 index) {}
119+
int64 value_dim, int64 index) {
120+
return false;
121+
}
120122
virtual bool insert_or_accum(K key, ConstTensor2D<V>& value_or_delta_flat,
121-
bool exist, int64 value_dim, int64 index) {}
123+
bool exist, int64 value_dim, int64 index) {
124+
return false;
125+
}
122126
virtual void find(const K& key, Tensor2D<V>& value_flat,
123127
ConstTensor2D<V>& default_flat, int64 value_dim,
124128
bool is_full_size_default, int64 index) const {}
125129
virtual void find(const K& key, Tensor2D<V>& value_flat,
126130
ConstTensor2D<V>& default_flat, bool& exist,
127131
int64 value_dim, bool is_full_size_default,
128132
int64 index) const {}
129-
virtual size_t size() const {}
133+
virtual size_t size() const { return 0; }
130134
virtual void clear() {}
131135
virtual bool erase(const K& key) {}
132136
virtual Status export_values(OpKernelContext* ctx, int64 value_dim) {}

tensorflow_recommenders_addons/dynamic_embedding/core/kernels/lookup_impl/lookup_table_op_gpu.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ class TableWrapperBase {
7171
virtual void get(const K* d_keys, ValueType<V>* d_vals, bool* d_status,
7272
size_t len, ValueType<V>* d_def_val, cudaStream_t stream,
7373
bool is_full_size_default) const {}
74-
virtual size_t get_size(cudaStream_t stream) const {}
75-
virtual size_t get_capacity() const {}
74+
virtual size_t get_size(cudaStream_t stream) const { return 0; }
75+
virtual size_t get_capacity() const { return 0; }
7676
virtual void remove(const K* d_keys, size_t len, cudaStream_t stream) {}
7777
virtual void clear(cudaStream_t stream) {}
7878
};

tensorflow_recommenders_addons/dynamic_embedding/python/keras/layers/embedding.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,17 +311,23 @@ class FieldWiseEmbedding(BasicEmbedding):
311311
```python
312312
nslots = 3
313313
@tf.function
314-
def map_slot_fn(feature_id):
314+
def feature_to_slot(feature_id):
315315
field_id = tf.math.mod(feature_id, nslots)
316316
return field_id
317317
318318
ids = tf.constant([[23, 12, 0], [9, 13, 10]], dtype=tf.int64)
319-
embedding = de.layers.FieldWiseEmbedding(1, nslots, map_slot_fn)
319+
embedding = de.layers.FieldWiseEmbedding(2,
320+
nslots,
321+
slot_map_fn=feature_to_slot,
322+
initializer=tf.keras.initializer.Zeros())
323+
324+
out = embedding(ids)
325+
# [[[0., 0.], [0., 0.], [0., 1.]]
326+
# [[0., 0.], [0., 0.], [0., 1.]]]
320327
321328
prepared_keys = tf.range(0, 100, dtype=tf.int64)
322329
prepared_values = tf.ones((100, 2), dtype=tf.float32)
323330
embedding.params.upsert(prepared_keys, prepared_values)
324-
325331
out = embedding(ids)
326332
# [[2., 2.], [0., 0.], [1., 1.]]
327333
# [[1., 1.], [2., 2.], [0., 0.]]

tools/build_dev_container.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/usr/bin/env bash
22

33
set -x -e
4-
5-
DOCKER_BUILDKIT=1 docker build \
4+
docker build \
65
-f tools/docker/dev_container.Dockerfile \
76
--build-arg TF_VERSION=2.5.1 \
8-
--build-arg TF_PACKAGE=tensorflow-cpu \
9-
--target dev_container_cpu \
10-
-t tfaddons/dev_container:latest-cpu ./
7+
--build-arg TF_PACKAGE=tensorflow-gpu \
8+
--build-arg PY_VERSION=$PY_VERSION \
9+
--no-cache \
10+
--target dev_container \
11+
-t tfra/dev_container:latest-python$PY_VERSION ./

tools/docker/cpu_tests.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
FROM python:3.7 as build_wheel
33

44
ARG TF_VERSION=2.5.1
5-
ARG USE_BAZEL_VERSION=3.7.2
5+
ARG USE_BAZEL_VERSION=5.1.1
66
ARG MPI_VERSION="4.1.1"
77
ARG HOROVOD_VERSION="0.23.0"
88

0 commit comments

Comments
 (0)