Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix]Avoid Floating point exception (core dumped) when using RedisTable by empty ids inputs. #206

Merged
merged 4 commits into from
Jan 17, 2022

Conversation

MoFHeka
Copy link
Contributor

@MoFHeka MoFHeka commented Jan 6, 2022

Description

Avoid Floating point exception (core dumped) when using RedisTable by empty ids inputs. I'm ignoring that and that's what's going to happen dividing by zero.

Also make compatible with the optimizers inited from tf.keras.optimizers. Optimizers call from tf.keras.optimizers are not belong to the class optimizer_v2.OptimizerV2 when using tf2.6.

Add TF2.7.0 CI.
Add CUDA_COMPUTE_CAPABILITIES.
Delete Python 3.6 in CI.

Make compatible with TF2.7 in reduction_ops_impl.h
Tensorflow2.7 requires C++14 or above, changing the standard for CUDA compilation from C++11 to C++14.

Type of change

  • Bug fix
  • New Tutorial
  • Updated or additional documentation
  • Additional Testing
  • New Feature

Checklist:

  • I've properly formatted my code according to the guidelines
    • By running yapf
    • By running clang-format
  • This PR addresses an already submitted issue for TensorFlow Recommenders-Addons
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

How Has This Been Tested?

About RedisTable

import numpy as np
import tensorflow as tf
import tensorflow_recommenders_addons as tfra

redis_config = tfra.dynamic_embedding.RedisTableConfig(
    redis_config_abs_dir="test/config1.json")
redis_creator = tfra.dynamic_embedding.RedisTableCreator(redis_config)

var = tfra.dynamic_embedding.get_variable(
        name="user_dynamic_embeddings",
        dim=32,
        initializer=tf.keras.initializers.Zeros(),
        checkpoint=False,
        kv_creator=redis_creator)

embeddings, trainable_wrapper = tfra.dynamic_embedding.embedding_lookup(
        params=var,
        ids=np.array([],dtype=int),
        name="user-id-weights",
        return_trainable=True)

print(embeddings)

The printing output will be looked like this

tf.Tensor([], shape=(0, 32), dtype=float32)

About optimizer
When using optimizer like this would not raise a error.

optimizer = tf.keras.optimizers.Adam(learning_rate=1E-4, amsgrad=True)
optimizer = tfra.dynamic_embedding.DynamicEmbeddingOptimizer(optimizer)

@MoFHeka MoFHeka requested a review from rhdong as a code owner January 6, 2022 14:07
@MoFHeka MoFHeka changed the title Compatible with the optimizers inited from tf.keras.optimizers [fix]Compatible with the optimizers inited from tf.keras.optimizers Jan 6, 2022
@Lifann
Copy link
Member

Lifann commented Jan 7, 2022

I proposed an issue: tensorflow/tensorflow#53686

@MoFHeka MoFHeka changed the title [fix]Compatible with the optimizers inited from tf.keras.optimizers [fix]Avoid Floating point exception (core dumped) when using RedisTable by empty ids inputs. Jan 7, 2022
@MoFHeka MoFHeka force-pushed the redis-dev branch 12 times, most recently from 40ae65f to 3687340 Compare January 13, 2022 19:01
@MoFHeka MoFHeka requested review from rhdong and Lifann January 14, 2022 07:00
configure.py Outdated
def _VALID_BAZEL_VERSION(tf_version):
if tf_version < "2.0.0":
logging.warn(
"TensorFlow under version 2.0.0 is only limited because its Bazel version, and requires users to make some Bazel script changes from the previous COMMIT to compile properly."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is too long , make it multi-lines.

configure.py Outdated Show resolved Hide resolved
Avoid Floating point exception (core dumped) when using RedisTable by empty ids inputs.

Fix bug that crc32c_hash function may underflow.
Add TF2.7.0 CI.
Add CUDA_COMPUTE_CAPABILITIES.
Remove Python 3.6 in CI.
Tensorflow2.7 requires C++14 or above, changing the standard for CUDA compilation from C++11 to C++14.
@rhdong rhdong merged commit 813d26e into tensorflow:master Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants