#pragma once #include #include #include namespace torch::autograd { using hooks_list = std::vector>; struct CppFunctionTensorPreHook : public FunctionPreHook { CppFunctionTensorPreHook(std::shared_ptr hooks, size_t value_idx); variable_list operator()(const variable_list& values) override; std::shared_ptr hooks_; size_t value_idx_; }; struct CppFunctionSingleTensorPreHook : public FunctionPreHook { CppFunctionSingleTensorPreHook( std::function hook, size_t value_idx); variable_list operator()(const variable_list& values) override; void compiled_args( torch::dynamo::autograd::CompiledNodeArgs& args) const override; std::function hook_; size_t value_idx_; }; } // namespace torch::autograd