Matrix products for kinematics#
The shared matrix helpers preserve Torch broadcasting and differentiation.
Under torch.compile, FP32 and FP64 products with trailing 3-by-3 matrices
use pointwise reductions that can fuse with surrounding geometry. Eager
execution, other sizes and dtypes, and autocast regions use Torch matrix
multiplication. The dynamics model, motion-tracking task and tree kinematics
share these operations.
Package imports#
|
Multiply matrices with broadcast batch axes and preserve gradients. |
|
Apply matrices to vectors with broadcast batch axes and preserve gradients. |
- embodichain.compute.kinematics.matrix_product(left, right)[source]#
Multiply matrices with broadcast batch axes and preserve gradients.
- Parameters:
left (
Tensor) – Matrices with shape(..., M, K).right (
Tensor) – Matrices with shape(..., K, N)and broadcastable batch axes.
- Return type:
Tensor- Returns:
Matrix products with shape
(..., M, N). Compiled FP32/FP64 3-by-3 products use pointwise reductions that fuse with adjacent geometry. Other sizes, eager calls and autocast regions use Torch matrix multiplication.
- embodichain.compute.kinematics.matrix_vector_product(matrix, vector)[source]#
Apply matrices to vectors with broadcast batch axes and preserve gradients.
- Parameters:
matrix (
Tensor) – Matrices with shape(..., M, K).vector (
Tensor) – Vectors with shape(..., K)and broadcastable batch axes.
- Return type:
Tensor- Returns:
Vectors with shape
(..., M). Compiled FP32/FP64 3-by-3 products fuse their pointwise reduction; other sizes, eager calls and autocast regions use Torch matrix multiplication.
Implementation module#
- embodichain.compute.kinematics.matrix.matrix_product(left, right)[source]#
Multiply matrices with broadcast batch axes and preserve gradients.
- Parameters:
left (
Tensor) – Matrices with shape(..., M, K).right (
Tensor) – Matrices with shape(..., K, N)and broadcastable batch axes.
- Return type:
Tensor- Returns:
Matrix products with shape
(..., M, N). Compiled FP32/FP64 3-by-3 products use pointwise reductions that fuse with adjacent geometry. Other sizes, eager calls and autocast regions use Torch matrix multiplication.
- embodichain.compute.kinematics.matrix.matrix_vector_product(matrix, vector)[source]#
Apply matrices to vectors with broadcast batch axes and preserve gradients.
- Parameters:
matrix (
Tensor) – Matrices with shape(..., M, K).vector (
Tensor) – Vectors with shape(..., K)and broadcastable batch axes.
- Return type:
Tensor- Returns:
Vectors with shape
(..., M). Compiled FP32/FP64 3-by-3 products fuse their pointwise reduction; other sizes, eager calls and autocast regions use Torch matrix multiplication.