28 Tensor out = hook(input, output);
29 if (out.
shape() != output.
shape())
throw std::invalid_argument(
"MLP hook: the replacement must keep the MLP output's shape");
N-dimensional tensor. Owns its data buffer exclusively; a DeviceBackend* is injected (not owned) – th...
Definition tensor.hpp:29
const Shape & shape() const
This tensor's shape.
Definition tensor.hpp:113
Tensor ApplyMlpHook(const MlpHook &hook, const Tensor &input, const Tensor &output)
Runs hook and checks its result keeps the shape.
Definition mlp_hook.hpp:27
Definition acquisition_functions.hpp:16
std::function< Tensor(const Tensor &mlp_input, const Tensor &mlp_output)> MlpHook
Called with an MLP's input (after the block's norm, where it has one) and its output (the branch adde...
Definition mlp_hook.hpp:23
N-dimensional tensor – owns a buffer via DeviceBackend*, RAII (Rule of Five).