BruceDai003:

But I cann’t find anything like how MulBackward1 is implemented, like an op. Or am I looking into the wrong direction?


It’s generated during the build in torch/csrc/autograd/generated. In Functions.cpp:
variable_list MulBackward1::apply(variable_list&& grads) {
  IndexRangeGenerator gen;
  auto self_ix = gen.range(1);
  variable_list grad_inputs(gen.size());
  auto& grad = grads[0];
  bool any_grad_defined = any_variable_defined(grads);
  if (should_compute_output({ self_ix })) {
    auto grad_result = any_grad_defined ? (mul_tensor_backward(grad, at::scalar\
_to_tensor(other), self_scalar_type)) : Tensor();
    copy_range(grad_inputs, self_ix, grad_result);
  }
  return grad_inputs;
}

and some not so interesting Python wrapping in python_functions.cpp
The above is generated by the things in tools/autograd processing derivatives.yaml.