Skip to content

tf.gather Converting sparse IndexedSlices warning #38168

@gasteigerjo

Description

@gasteigerjo

System information

  • Have I written custom code (as opposed to using a stock
    example script provided in TensorFlow): yes
  • OS Platform and Distribution (e.g.,
    Linux Ubuntu 16.04): Ubuntu 16.04
  • TensorFlow installed from: binary (Anaconda)
  • TensorFlow version: 2.1
  • Python version: 3.7.7
  • CUDA/cuDNN version: 10.1/7.6.5
  • GPU model and memory: GeForce 1080 Ti

Describe the current behavior
Whenever tf.gather (or tf.boolean_mask) is called with params (tensor) being the output of another function, this throws the warning UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory. This behavior seems to be well known but largely ignored/accepted. Calling tf.gather on the output of another function is perfectly reasonable and should in my opinion not throw a warning.

Describe the expected behavior
The forward pass should infer the shape of the dense tensor required in the backward pass, if possible (issue with dynamic shapes?). No warning should be thrown or the user should be able to acknowledge/deactivate the warning (ideally a warning that is more specific than the current one).

Standalone code to reproduce the issue
See e.g. https://github.com/klicperajo/dimenet/blob/master/train.ipynb

Other info / logs
https://stackoverflow.com/questions/35892412/tensorflow-dense-gradient-explanation
Related: #23566

Metadata

Metadata

Labels

TF 2.9Issues found in the TF 2.9 release (or RCs)comp:opsOPs related issuesstaleThis label marks the issue/pr stale - to be closed automatically if no activitystat:awaiting responseStatus - Awaiting response from authortype:bugBug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions