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

Open
#1,477 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp, pytorch

Research direction

Start with the stub at src/TorchSharp/Tensor/torch.OtherOperations.cs around line 468, then inspect ATen/ops/histogramdd.h and nearby TorchSharp bindings for the expected native-to-C# path. Use the PyTorch histogramdd documentation as the behavioral reference; done means the TorchSharp method no longer throws and produces the expected N-D histogram results without requiring a manual workaround.

Written by the indexing model from the issue text.

Description

Missing Feature

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: https://github.com/dotnet/TorchSharp/blob/75eab9ff095de96454d6dbf053e6429acdd6bb84/src/TorchSharp/Tensor/torch.OtherOperations.cs#L468

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.

Dominant language
C#
Stars
1.9k
Forks
228
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/TorchSharp

All issues in dotnet/TorchSharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.