pytorch/torch/csrc/jit/runtime
zeshengzong 97272e4b49 Fix torch.nn.functional.hardswish gradients corner case (#148049)
Fixes #147801

## Changes

- Change hardswish gradient compute condition as [torch.nn.functional.hardswish](https://pytorch.org/docs/stable/generated/torch.nn.functional.hardswish.html)
- Enable cuda for test `test_hardswish_grad_corner`
- Add test case for value=-3

## Test Result

```bash
pytest test/test_nn.py -k test_hardswish
pytest test/test_unary_ufuncs.py -k test_hardswish
pytest test/inductor/test_torchinductor.py -k test_hardswish
```

![image](https://github.com/user-attachments/assets/000cb5c4-15f5-4bfd-ab45-f52bf810ff3d)
![image](https://github.com/user-attachments/assets/38b08cf8-ea84-47a2-8e37-0a213da3e0c8)
![image](https://github.com/user-attachments/assets/54bc57be-2c57-46cc-ab90-94ea6cbe1c34)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/148049
Approved by: https://github.com/soulitzer
2025-03-14 18:53:10 +00:00
..
interpreter Fix clang-tidy warnings in torch/jit (#146963) 2025-02-15 03:36:59 +00:00
static [PT2]: allow empty dict to pass type check (#147167) (#147480) 2025-02-21 07:00:46 +00:00
argument_spec.cpp
argument_spec.h Remove unnecessary tensor clone (#148159) 2025-03-02 16:21:39 +00:00
autodiff.cpp
autodiff.h
calculate_necessary_args.h
custom_operator.h
decomposition_registry_util.cpp
decomposition_registry_util.h
decomposition_registry.cpp
decomposition_registry.h
exception_message.h
graph_executor_impl.h
graph_executor.cpp Remove unnecessary tensor clone (#148159) 2025-03-02 16:21:39 +00:00
graph_executor.h
graph_iterator.h
instruction.cpp
instruction.h
interpreter.cpp
interpreter.h
jit_exception.cpp Fix clang-tidy warnings in torch/jit (#146963) 2025-02-15 03:36:59 +00:00
jit_exception.h
jit_trace.cpp
jit_trace.h
logging.cpp
logging.h Fix clang-tidy warnings in torch/jit (#146963) 2025-02-15 03:36:59 +00:00
operator_options.h
operator.cpp
operator.h
print_handler.cpp
print_handler.h
profiling_graph_executor_impl.cpp
profiling_graph_executor_impl.h
profiling_record.cpp
profiling_record.h
register_c10_ops.cpp
register_cuda_ops.cpp
register_distributed_ops.cpp
register_ops_utils.cpp
register_ops_utils.h
register_prim_ops_fulljit.cpp
register_prim_ops.cpp Fix clang-tidy warnings in torch/jit (#146963) 2025-02-15 03:36:59 +00:00
register_special_ops.cpp
script_profile.cpp
script_profile.h
serialized_shape_function_registry.cpp
serialized_shape_function_registry.h
shape_function_registry.h
simple_graph_executor_impl.cpp
simple_graph_executor_impl.h
slice_indices_adjust.cpp
slice_indices_adjust.h
symbolic_script.cpp Fix torch.nn.functional.hardswish gradients corner case (#148049) 2025-03-14 18:53:10 +00:00
symbolic_script.h
symbolic_shape_registry_util.cpp
symbolic_shape_registry_util.h
symbolic_shape_registry.cpp
symbolic_shape_registry.h
vararg_functions.cpp
vararg_functions.h
variable_tensor_list.h