Skip to content

Request to add torch.histogramdd (multi-dimensional histogram) in TorchSharp #1477

Description

@ncguilbeault

Overview

Hello and thank you for all the work that goes into TorchSharp — it has been a very useful tool for us!

I recently needed to compute an N-D histogram from a Tensor object. In PyTorch, this is provided by torch.histogramdd (introduced in 1.11 and still present in the latest 2.7): https://pytorch.org/docs/stable/generated/torch.histogramdd.html

In TorchSharp, the method signature was added 2 years ago but remains as only a stub which throws a NotImplementedException:

static (Tensor hist_values, Tensor[] edges) histogramdd(

Why is it useful?

Building N-D histograms from tensor data is quite powerful. For instance, this is useful for calculating occupancy grids over multiple dimensions, computing information loss, color image histograms, etc. Currently, to do this with TorchSharp requires work-arounds using other libraries or manual implementation. It could also benefit from running on the same hardware and minimizing unnecessary CPU-GPU transfers.

Feasibility

The native function already ships with LibTorch (ATen/ops/histogramdd.h), so perhaps only the C++/CLI binding and C# wrapper is needed? If possible, it would be great to have this added into an upcoming release.

If it's any help, I'm happy to take a first pass at a PR for this. Please let me know if there are design constraints or coding conventions I should follow before I start.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions