What happens if I transfer the Python code "p.grad=none" to the c++ code?

Hi

I tried to transfer python to c++.

in python code
p.grad = none

in c++ code
i don’t know what i have to use c++ function
p.grad() = ???;
p.grad().???;

vs2022
libtorch cpu release

please help me

Does p.mutuable_grad().reset() work?

Best regards

Thomas

thanks for reply

“p.mutuable_grad().reset();” Build and run is done.

The verification remains.

I’ll verify it and share the results with you.

thank you.