Skip to content

[Contributor Welcome] Implement C++ API version of torch.nn.functional.pdist #27082

@yf225

Description

@yf225

Context

We would like to add torch::nn::functional::pdist to the C++ API, so that C++ users can easily find the equivalent of Python API torch.nn.functional.pdist.

Steps

  • Add torch::nn::functional::pdist(...) in torch/csrc/api/include/torch/nn/functional/distance.h (add this file if it doesn’t exist). The function should have the following signature:
namespace torch {
namespace nn {
namespace functional {

inline Tensor pdist(
    const Tensor& input,
    int64_t p = 2) {
  ...
}

} // namespace functional
} // namespace nn
} // namespace torch
  • Add test for torch::nn::functional::pdist(...) in test/cpp/api/functional.cpp. It can just check whether the function output is as expected for some simple cases.

Helpful Resources

There are quite a few PRs for adding new functionals / new modules for the C++ API (the list of PRs is in #25883), which can serve as great references. Also please ping @yf225 on this issue if you encounter any problems.

How do I claim this feature request?

Please comment in this issue if you are interested in working on it.

cc @yf225

Metadata

Metadata

Assignees

Labels

good first issuemodule: cppRelated to C++ APItriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions