Skip to content

Commit

Permalink
[fix] clean disk space to avoid out of disk problem in the ci
Browse files Browse the repository at this point in the history
  • Loading branch information
jq committed Oct 3, 2024
1 parent 9b241a4 commit bc6191f
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/make_wheel_Linux_x86.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ if [[ "$TF_VERSION" =~ ^2\.1[3-9]\.[0-9]$ ]] ; then
export PROTOBUF_VERSION='4.23.4'
fi

docker system prune -f

DOCKER_BUILDKIT=1 docker build --no-cache \
-f tools/docker/build_wheel.Dockerfile \
--output type=local,dest=wheelhouse \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,52 @@
from tensorflow.keras.legacy.optimizers import Adam


class MyModel(layers.Layer):

def __init__(self):
super().__init__()
self.embeddings = de.get_variable(name="p1")

@tf.function
def call(self, indices_input, ids_input):
shape_input = tf.constant([2, 3, 4], dtype=tf.int64)

sparse_ids = tf.sparse.SparseTensor(indices=indices_input,
values=ids_input,
dense_shape=shape_input)

embeddings_result = de.safe_embedding_lookup_sparse(self.embeddings,
sparse_ids,
name="safe_sp_emb",
return_trainable=False)
return embeddings_result


# class MyModel(tf.Module):
# def __init__(self):
# super().__init__()
# # Create the variable as an attribute of the module
# self.embeddings = de.get_variable(name="p1")
#
# @tf.function
# def __call__(self, indices_input, ids_input):
# shape_input = tf.constant([2, 3, 4], dtype=tf.int64)
#
# sparse_ids = tf.sparse.SparseTensor(
# indices=indices_input,
# values=ids_input,
# dense_shape=shape_input
# )
#
# embeddings_result = de.safe_embedding_lookup_sparse(
# self.embeddings,
# sparse_ids,
# name="safe_sp_emb",
# return_trainable=False
# )
# return embeddings_result


# pylint: disable=missing-class-docstring
# pylint: disable=missing-function-docstring
def _type_converter(tf_type):
Expand Down Expand Up @@ -570,20 +616,6 @@ def test_scope_reuse_sparse_embedding_lookup(self):
self.assertAllEqual(p2._tables[0].name, "test_p2_mht_1of1")

def test_keras_input_safe_sparse_embedding_lookup(self):
embeddings = de.get_variable(name="p1")

@tf.function
def model(indices_input, ids_input):
shape_input = tf.constant([2, 3, 4], dtype=tf.int64)

sparse_ids = tf.sparse.SparseTensor(indices=indices_input,
values=ids_input,
dense_shape=shape_input)

embeddings_result = de.safe_embedding_lookup_sparse(
embeddings, sparse_ids, name="safe_sp_emb", return_trainable=False)
return embeddings_result

indices_data = tf.constant([
[0, 0, 0],
[0, 0, 1],
Expand All @@ -593,9 +625,10 @@ def model(indices_input, ids_input):
[1, 1, 0],
[1, 1, 1],
],
name="indices_data",
dtype=tf.int64)
ids_data = tf.constant([0, 1, -1, -1, 2, 0, 1], dtype=tf.int64)

ids_data = tf.constant([0, 1, -1, -1, 2, 0, 1], name="ids", dtype=tf.int64)
model = MyModel()
# output = model(indices_data, ids_data)

def test_scope_reuse_safe_sparse_embedding_lookup(self):
Expand Down
7 changes: 5 additions & 2 deletions tools/testing/build_and_run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ if [ "$TF_VERSION" = "2.6.3" ] ; then
python -m pip install numpy==1.19.5 --force-reinstall
fi

bazel clean --expunge

# Avoid SystemError: initialization of _pywrap_checkpoint_reader raised unreported exception
pip install tensorflow==$TF_VERSION

Expand Down Expand Up @@ -79,8 +81,9 @@ fi

python -m pytest -v -s --functions-durations=20 --modules-durations=5 $IGNORE_HKV $SKIP_CUSTOM_OP_TESTS_FLAG $EXTRA_ARGS ./tensorflow_recommenders_addons/dynamic_embedding/python/kernel_tests/



# Release disk space
bazel clean --expunge
rm -f ./tensorflow_recommenders_addons/dynamic_embedding/core/_*_ops.so
rm -rf /tmp/*
apt-get clean && rm -rf /var/lib/apt/lists/*
rm -rf /var/log/*

0 comments on commit bc6191f

Please sign in to comment.