Meth Class — pytorch Architecture
Architecture documentation for the Meth class in BatchRulesBinaryOps.cpp from the pytorch codebase.
Entity Profile
Source Code
aten/src/ATen/functorch/BatchRulesBinaryOps.cpp lines 93–118
template <typename M, M Meth, typename... ExtraArgs>
static void binary_pointwise_inplace_batch_rule(
Tensor& tensor, std::optional<int64_t> tensor_batch_dim,
const Tensor& other, std::optional<int64_t> other_batch_dim,
ExtraArgs... extra_args) {
if (!tensor_batch_dim && other_batch_dim) {
vmapIncompatibleInplaceError("inplace arithmetic");
}
// compute max logical rank
auto tensor_logical_rank = rankWithoutBatchDim(tensor, tensor_batch_dim);
auto other_logical_rank = rankWithoutBatchDim(other, other_batch_dim);
auto max_logical_rank = std::max(tensor_logical_rank, other_logical_rank);
auto tensor_ = moveBatchDimToFront(tensor, tensor_batch_dim);
auto other_ = moveBatchDimToFront(other, other_batch_dim);
// If the dimensions aren't aligned, we need to line them up.
// Tensor[B, 3] + Tensor[2, 5, 3] -> Tensor[B, 1, 1, 3] + Tensor[2, 5, 3]
// Note that only tensors that have a batch dim need to be modified.
// Tensor[B, 2, 3, 5] + Tensor[5] -> no changes needed
tensor_ = maybePadToLogicalRank(tensor_, tensor_batch_dim, max_logical_rank);
other_ = maybePadToLogicalRank(other_, other_batch_dim, max_logical_rank);
(tensor_.*Meth)(other_, std::forward<ExtraArgs>(extra_args)...);
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free