KEMBAR78
C++ functional::smooth_l1_loss overrides beta in options with default · Issue #70163 · pytorch/pytorch · GitHub
Skip to content

C++ functional::smooth_l1_loss overrides beta in options with default #70163

@meganset

Description

@meganset

🐛 Describe the bug

Pull request #44433 added beta to the SmoothL1Options structure but overrides it in the functional call:

In nn/functional/loss.h:

inline Tensor smooth_l1_loss(
    const Tensor& input,
    const Tensor& target,
    const SmoothL1LossFuncOptions& options = {},
    double beta = 1.) {
  return detail::smooth_l1_loss(input, target, options.reduction(), beta);
}

If a beta is specified in the options, it will be overridden by the default in a call like:

torch::nn::functional::smooth_l1_loss(inputs, targets, options.beta(.5));

I think the definition in nn/functional/loss.h should remove the added beta in the arguments and reference it in the call to the detail function:

inline Tensor smooth_l1_loss(
    const Tensor& input,
    const Tensor& target,
    const SmoothL1LossFuncOptions& options = {})
  return detail::smooth_l1_loss(input, target, options.reduction(), options.beta());
}

Versions

All libtorch versions from 1.7.0

cc @ezyang @gchanan @zou3519 @bdhirsh @jbschlosser

Metadata

Metadata

Assignees

Labels

actionablehigh prioritymodule: correctness (silent)issue that returns an incorrect result silentlymodule: cppRelated to C++ APImodule: lossProblem is related to loss functiontriagedThis 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