[go: up one dir, main page]

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

Broadcasting sparse indices #38429

Open
ngc92 opened this issue Apr 10, 2020 · 0 comments
Open

Broadcasting sparse indices #38429

ngc92 opened this issue Apr 10, 2020 · 0 comments
Assignees
Labels
comp:ops OPs related issues stat:awaiting tensorflower Status - Awaiting response from tensorflower type:feature Feature requests

Comments

@ngc92
Copy link
Contributor
ngc92 commented Apr 10, 2020

System information

  • TensorFlow version (you are using): 2.1
  • Are you willing to contribute it (Yes/No): Yes (partially, what can be done on the python side, and maybe CPU kernels)

Will this change the current api? How?
Add an operation to tf.sparse.broadcast_indices (feel free to suggest a beter name), doing the following:

tf.sparse.broadcast_indices(a, b, default_value): Given two sparse tensors of same dense shape, inserts `default_value` at positions such that a.indices == b.indices.

This would provide a basic building block for arbitrary pointwise-binary operations on SparseTensors. Therefore I would also suggest adding a function like

tf.sparse.map_binary_op(a, b, op, def_value=0):
   a, b = broadcast_indices(a, b, def_value)
   return SparseTensor(a.indices, op(a.values, b.values), a.shape) 

This would then allow for more efficient implementations e.g. of binary metrics when both labels and predictions are sparse, e.g. when calculating P@k statistics.

I think I can provide an initial, sub-optimal implementation that builds this on top of tf.sparse.add for default values of zero. Would you be interested in a PR like that (maybe putting it into experimental namespace at first)?

@ngc92 ngc92 added the type:feature Feature requests label Apr 10, 2020
@saikumarchalla saikumarchalla added the comp:ops OPs related issues label Apr 13, 2020
@jvishnuvardhan jvishnuvardhan added the stat:awaiting tensorflower Status - Awaiting response from tensorflower label Nov 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:ops OPs related issues stat:awaiting tensorflower Status - Awaiting response from tensorflower type:feature Feature requests
Projects
None yet
Development

No branches or pull requests

4 participants