Skip to content

[Contributor Welcome] Implement C++ API version of torch.nn.functional.affine_grid #27196

@yf225

Description

@yf225

Context

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

Steps

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

inline Tensor affine_grid(
    const Tensor& theta,
    const IntArrayRef& size,
    bool align_corners = false) {
  ...
}

} // namespace functional
} // namespace nn
} // namespace torch
  • Add tests for torch::nn::functional::affine_grid(...) in test/cpp/api/functional.cpp. It would be great to provide different values for theta / size / align_corners , and check that the output values are as expected (aka. same as the output values from Python). Also we should add tests to check that all errors are thrown correctly, by using ASSERT_THROWS_WITH .

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

enhancementNot as big of a feature, but technically not a bug. Should be easy to fixgood 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