curobo.geom.transform module
- curobo.geom.transform.transform_points(position, quaternion, points, out_points=None, out_gp=None, out_gq=None, out_gpt=None)
- curobo.geom.transform.batch_transform_points(position, quaternion, points, out_points=None, out_gp=None, out_gq=None, out_gpt=None)
- curobo.geom.transform.matrix_to_quaternion(matrix, out_quat=None, adj_matrix=None)
- curobo.geom.transform.cuda_matrix_to_quaternion(matrix)
Convert rotations given as rotation matrices to quaternions. :param matrix: Rotation matrices as tensor of shape (…, 3, 3).
- Returns:
quaternions with real part first, as tensor of shape (…, 4). [qw, qx,qy,qz]
- curobo.geom.transform.quaternion_to_matrix(quaternions, out_mat=None, adj_quaternion=None)
- curobo.geom.transform.torch_quaternion_to_matrix(quaternions)
Convert rotations given as quaternions to rotation matrices.
- Parameters:
quaternions – quaternions with real part first, as tensor of shape (…, 4).
- Returns:
Rotation matrices as tensor of shape (…, 3, 3).
- curobo.geom.transform.pose_to_matrix(position, quaternion, out_matrix=None)
- Parameters:
position (Tensor) –
quaternion (Tensor) –
out_matrix (Tensor | None) –
- curobo.geom.transform.pose_multiply(position, quaternion, position2, quaternion2, out_position=None, out_quaternion=None, adj_pos=None, adj_quat=None, adj_pos2=None, adj_quat2=None)
- curobo.geom.transform.pose_inverse(position, quaternion, out_position=None, out_quaternion=None, adj_pos=None, adj_quat=None)
- class curobo.geom.transform.TransformPoint(*args, **kwargs)
Bases:
Function
- static forward(ctx, position, quaternion, points, out_points, adj_position, adj_quaternion, adj_points)
This function is to be overridden by all subclasses. There are two ways to define forward:
Usage 1 (Combined forward and ctx):
@staticmethod def forward(ctx: Any, *args: Any, **kwargs: Any) -> Any: pass
It must accept a context ctx as the first argument, followed by any number of arguments (tensors or other types).
See combining-forward-context for more details
Usage 2 (Separate forward and ctx):
@staticmethod def forward(*args: Any, **kwargs: Any) -> Any: pass @staticmethod def setup_context(ctx: Any, inputs: Tuple[Any, ...], output: Any) -> None: pass
The forward no longer accepts a ctx argument.
Instead, you must also override the
torch.autograd.Function.setup_context
staticmethod to handle setting up thectx
object.output
is the output of the forward,inputs
are a Tuple of inputs to the forward.See extending-autograd for more details
The context can be used to store arbitrary data that can be then retrieved during the backward pass. Tensors should not be stored directly on ctx (though this is not currently enforced for backward compatibility). Instead, tensors should be saved either with
ctx.save_for_backward
if they are intended to be used inbackward
(equivalently,vjp
) orctx.save_for_forward
if they are intended to be used for injvp
.- Parameters:
position (Tensor) –
quaternion (Tensor) –
points (Tensor) –
out_points (Tensor) –
adj_position (Tensor) –
adj_quaternion (Tensor) –
adj_points (Tensor) –
- static backward(ctx, grad_output)
Defines a formula for differentiating the operation with backward mode automatic differentiation (alias to the vjp function).
This function is to be overridden by all subclasses.
It must accept a context
ctx
as the first argument, followed by as many outputs as theforward
returned (None will be passed in for non tensor outputs of the forward function), and it should return as many tensors, as there were inputs toforward
. Each argument is the gradient w.r.t the given output, and each returned value should be the gradient w.r.t. the corresponding input. If an input is not a Tensor or is a Tensor not requiring grads, you can just pass None as a gradient for that input.The context can be used to retrieve tensors saved during the forward pass. It also has an attribute
ctx.needs_input_grad
as a tuple of booleans representing whether each input needs gradient. E.g.,backward
will havectx.needs_input_grad[0] = True
if the first input toforward
needs gradient computed w.r.t. the output.
- _backward_cls
alias of
TransformPointBackward
- class curobo.geom.transform.BatchTransformPoint(*args, **kwargs)
Bases:
Function
- static forward(ctx, position, quaternion, points, out_points, adj_position, adj_quaternion, adj_points)
This function is to be overridden by all subclasses. There are two ways to define forward:
Usage 1 (Combined forward and ctx):
@staticmethod def forward(ctx: Any, *args: Any, **kwargs: Any) -> Any: pass
It must accept a context ctx as the first argument, followed by any number of arguments (tensors or other types).
See combining-forward-context for more details
Usage 2 (Separate forward and ctx):
@staticmethod def forward(*args: Any, **kwargs: Any) -> Any: pass @staticmethod def setup_context(ctx: Any, inputs: Tuple[Any, ...], output: Any) -> None: pass
The forward no longer accepts a ctx argument.
Instead, you must also override the
torch.autograd.Function.setup_context
staticmethod to handle setting up thectx
object.output
is the output of the forward,inputs
are a Tuple of inputs to the forward.See extending-autograd for more details
The context can be used to store arbitrary data that can be then retrieved during the backward pass. Tensors should not be stored directly on ctx (though this is not currently enforced for backward compatibility). Instead, tensors should be saved either with
ctx.save_for_backward
if they are intended to be used inbackward
(equivalently,vjp
) orctx.save_for_forward
if they are intended to be used for injvp
.- Parameters:
position (Tensor) –
quaternion (Tensor) –
points (Tensor) –
out_points (Tensor) –
adj_position (Tensor) –
adj_quaternion (Tensor) –
adj_points (Tensor) –
- static backward(ctx, grad_output)
Defines a formula for differentiating the operation with backward mode automatic differentiation (alias to the vjp function).
This function is to be overridden by all subclasses.
It must accept a context
ctx
as the first argument, followed by as many outputs as theforward
returned (None will be passed in for non tensor outputs of the forward function), and it should return as many tensors, as there were inputs toforward
. Each argument is the gradient w.r.t the given output, and each returned value should be the gradient w.r.t. the corresponding input. If an input is not a Tensor or is a Tensor not requiring grads, you can just pass None as a gradient for that input.The context can be used to retrieve tensors saved during the forward pass. It also has an attribute
ctx.needs_input_grad
as a tuple of booleans representing whether each input needs gradient. E.g.,backward
will havectx.needs_input_grad[0] = True
if the first input toforward
needs gradient computed w.r.t. the output.
- _backward_cls
alias of
BatchTransformPointBackward
- class curobo.geom.transform.BatchTransformPose(*args, **kwargs)
Bases:
Function
- static forward(ctx, position, quaternion, position2, quaternion2, out_position, out_quaternion, adj_position, adj_quaternion, adj_position2, adj_quaternion2)
This function is to be overridden by all subclasses. There are two ways to define forward:
Usage 1 (Combined forward and ctx):
@staticmethod def forward(ctx: Any, *args: Any, **kwargs: Any) -> Any: pass
It must accept a context ctx as the first argument, followed by any number of arguments (tensors or other types).
See combining-forward-context for more details
Usage 2 (Separate forward and ctx):
@staticmethod def forward(*args: Any, **kwargs: Any) -> Any: pass @staticmethod def setup_context(ctx: Any, inputs: Tuple[Any, ...], output: Any) -> None: pass
The forward no longer accepts a ctx argument.
Instead, you must also override the
torch.autograd.Function.setup_context
staticmethod to handle setting up thectx
object.output
is the output of the forward,inputs
are a Tuple of inputs to the forward.See extending-autograd for more details
The context can be used to store arbitrary data that can be then retrieved during the backward pass. Tensors should not be stored directly on ctx (though this is not currently enforced for backward compatibility). Instead, tensors should be saved either with
ctx.save_for_backward
if they are intended to be used inbackward
(equivalently,vjp
) orctx.save_for_forward
if they are intended to be used for injvp
.- Parameters:
position (Tensor) –
quaternion (Tensor) –
position2 (Tensor) –
quaternion2 (Tensor) –
out_position (Tensor) –
out_quaternion (Tensor) –
adj_position (Tensor) –
adj_quaternion (Tensor) –
adj_position2 (Tensor) –
adj_quaternion2 (Tensor) –
- static backward(ctx, grad_out_position, grad_out_quaternion)
Defines a formula for differentiating the operation with backward mode automatic differentiation (alias to the vjp function).
This function is to be overridden by all subclasses.
It must accept a context
ctx
as the first argument, followed by as many outputs as theforward
returned (None will be passed in for non tensor outputs of the forward function), and it should return as many tensors, as there were inputs toforward
. Each argument is the gradient w.r.t the given output, and each returned value should be the gradient w.r.t. the corresponding input. If an input is not a Tensor or is a Tensor not requiring grads, you can just pass None as a gradient for that input.The context can be used to retrieve tensors saved during the forward pass. It also has an attribute
ctx.needs_input_grad
as a tuple of booleans representing whether each input needs gradient. E.g.,backward
will havectx.needs_input_grad[0] = True
if the first input toforward
needs gradient computed w.r.t. the output.
- _backward_cls
alias of
BatchTransformPoseBackward
- class curobo.geom.transform.TransformPose(*args, **kwargs)
Bases:
Function
- static forward(ctx, position, quaternion, position2, quaternion2, out_position, out_quaternion, adj_position, adj_quaternion, adj_position2, adj_quaternion2)
This function is to be overridden by all subclasses. There are two ways to define forward:
Usage 1 (Combined forward and ctx):
@staticmethod def forward(ctx: Any, *args: Any, **kwargs: Any) -> Any: pass
It must accept a context ctx as the first argument, followed by any number of arguments (tensors or other types).
See combining-forward-context for more details
Usage 2 (Separate forward and ctx):
@staticmethod def forward(*args: Any, **kwargs: Any) -> Any: pass @staticmethod def setup_context(ctx: Any, inputs: Tuple[Any, ...], output: Any) -> None: pass
The forward no longer accepts a ctx argument.
Instead, you must also override the
torch.autograd.Function.setup_context
staticmethod to handle setting up thectx
object.output
is the output of the forward,inputs
are a Tuple of inputs to the forward.See extending-autograd for more details
The context can be used to store arbitrary data that can be then retrieved during the backward pass. Tensors should not be stored directly on ctx (though this is not currently enforced for backward compatibility). Instead, tensors should be saved either with
ctx.save_for_backward
if they are intended to be used inbackward
(equivalently,vjp
) orctx.save_for_forward
if they are intended to be used for injvp
.- Parameters:
position (Tensor) –
quaternion (Tensor) –
position2 (Tensor) –
quaternion2 (Tensor) –
out_position (Tensor) –
out_quaternion (Tensor) –
adj_position (Tensor) –
adj_quaternion (Tensor) –
adj_position2 (Tensor) –
adj_quaternion2 (Tensor) –
- static backward(ctx, grad_out_position, grad_out_quaternion)
Defines a formula for differentiating the operation with backward mode automatic differentiation (alias to the vjp function).
This function is to be overridden by all subclasses.
It must accept a context
ctx
as the first argument, followed by as many outputs as theforward
returned (None will be passed in for non tensor outputs of the forward function), and it should return as many tensors, as there were inputs toforward
. Each argument is the gradient w.r.t the given output, and each returned value should be the gradient w.r.t. the corresponding input. If an input is not a Tensor or is a Tensor not requiring grads, you can just pass None as a gradient for that input.The context can be used to retrieve tensors saved during the forward pass. It also has an attribute
ctx.needs_input_grad
as a tuple of booleans representing whether each input needs gradient. E.g.,backward
will havectx.needs_input_grad[0] = True
if the first input toforward
needs gradient computed w.r.t. the output.
- _backward_cls
alias of
TransformPoseBackward
- class curobo.geom.transform.PoseInverse(*args, **kwargs)
Bases:
Function
- static forward(ctx, position, quaternion, out_position, out_quaternion, adj_position, adj_quaternion)
This function is to be overridden by all subclasses. There are two ways to define forward:
Usage 1 (Combined forward and ctx):
@staticmethod def forward(ctx: Any, *args: Any, **kwargs: Any) -> Any: pass
It must accept a context ctx as the first argument, followed by any number of arguments (tensors or other types).
See combining-forward-context for more details
Usage 2 (Separate forward and ctx):
@staticmethod def forward(*args: Any, **kwargs: Any) -> Any: pass @staticmethod def setup_context(ctx: Any, inputs: Tuple[Any, ...], output: Any) -> None: pass
The forward no longer accepts a ctx argument.
Instead, you must also override the
torch.autograd.Function.setup_context
staticmethod to handle setting up thectx
object.output
is the output of the forward,inputs
are a Tuple of inputs to the forward.See extending-autograd for more details
The context can be used to store arbitrary data that can be then retrieved during the backward pass. Tensors should not be stored directly on ctx (though this is not currently enforced for backward compatibility). Instead, tensors should be saved either with
ctx.save_for_backward
if they are intended to be used inbackward
(equivalently,vjp
) orctx.save_for_forward
if they are intended to be used for injvp
.- Parameters:
position (Tensor) –
quaternion (Tensor) –
out_position (Tensor) –
out_quaternion (Tensor) –
adj_position (Tensor) –
adj_quaternion (Tensor) –
- static backward(ctx, grad_out_position, grad_out_quaternion)
Defines a formula for differentiating the operation with backward mode automatic differentiation (alias to the vjp function).
This function is to be overridden by all subclasses.
It must accept a context
ctx
as the first argument, followed by as many outputs as theforward
returned (None will be passed in for non tensor outputs of the forward function), and it should return as many tensors, as there were inputs toforward
. Each argument is the gradient w.r.t the given output, and each returned value should be the gradient w.r.t. the corresponding input. If an input is not a Tensor or is a Tensor not requiring grads, you can just pass None as a gradient for that input.The context can be used to retrieve tensors saved during the forward pass. It also has an attribute
ctx.needs_input_grad
as a tuple of booleans representing whether each input needs gradient. E.g.,backward
will havectx.needs_input_grad[0] = True
if the first input toforward
needs gradient computed w.r.t. the output.
- _backward_cls
alias of
PoseInverseBackward
- class curobo.geom.transform.QuatToMatrix(*args, **kwargs)
Bases:
Function
- static forward(ctx, quaternion, out_mat, adj_quaternion)
This function is to be overridden by all subclasses. There are two ways to define forward:
Usage 1 (Combined forward and ctx):
@staticmethod def forward(ctx: Any, *args: Any, **kwargs: Any) -> Any: pass
It must accept a context ctx as the first argument, followed by any number of arguments (tensors or other types).
See combining-forward-context for more details
Usage 2 (Separate forward and ctx):
@staticmethod def forward(*args: Any, **kwargs: Any) -> Any: pass @staticmethod def setup_context(ctx: Any, inputs: Tuple[Any, ...], output: Any) -> None: pass
The forward no longer accepts a ctx argument.
Instead, you must also override the
torch.autograd.Function.setup_context
staticmethod to handle setting up thectx
object.output
is the output of the forward,inputs
are a Tuple of inputs to the forward.See extending-autograd for more details
The context can be used to store arbitrary data that can be then retrieved during the backward pass. Tensors should not be stored directly on ctx (though this is not currently enforced for backward compatibility). Instead, tensors should be saved either with
ctx.save_for_backward
if they are intended to be used inbackward
(equivalently,vjp
) orctx.save_for_forward
if they are intended to be used for injvp
.- Parameters:
quaternion (Tensor) –
out_mat (Tensor) –
adj_quaternion (Tensor) –
- static backward(ctx, grad_out_mat)
Defines a formula for differentiating the operation with backward mode automatic differentiation (alias to the vjp function).
This function is to be overridden by all subclasses.
It must accept a context
ctx
as the first argument, followed by as many outputs as theforward
returned (None will be passed in for non tensor outputs of the forward function), and it should return as many tensors, as there were inputs toforward
. Each argument is the gradient w.r.t the given output, and each returned value should be the gradient w.r.t. the corresponding input. If an input is not a Tensor or is a Tensor not requiring grads, you can just pass None as a gradient for that input.The context can be used to retrieve tensors saved during the forward pass. It also has an attribute
ctx.needs_input_grad
as a tuple of booleans representing whether each input needs gradient. E.g.,backward
will havectx.needs_input_grad[0] = True
if the first input toforward
needs gradient computed w.r.t. the output.
- _backward_cls
alias of
QuatToMatrixBackward
- class curobo.geom.transform.MatrixToQuaternion(*args, **kwargs)
Bases:
Function
- static forward(ctx, in_mat, out_quaternion, adj_mat)
This function is to be overridden by all subclasses. There are two ways to define forward:
Usage 1 (Combined forward and ctx):
@staticmethod def forward(ctx: Any, *args: Any, **kwargs: Any) -> Any: pass
It must accept a context ctx as the first argument, followed by any number of arguments (tensors or other types).
See combining-forward-context for more details
Usage 2 (Separate forward and ctx):
@staticmethod def forward(*args: Any, **kwargs: Any) -> Any: pass @staticmethod def setup_context(ctx: Any, inputs: Tuple[Any, ...], output: Any) -> None: pass
The forward no longer accepts a ctx argument.
Instead, you must also override the
torch.autograd.Function.setup_context
staticmethod to handle setting up thectx
object.output
is the output of the forward,inputs
are a Tuple of inputs to the forward.See extending-autograd for more details
The context can be used to store arbitrary data that can be then retrieved during the backward pass. Tensors should not be stored directly on ctx (though this is not currently enforced for backward compatibility). Instead, tensors should be saved either with
ctx.save_for_backward
if they are intended to be used inbackward
(equivalently,vjp
) orctx.save_for_forward
if they are intended to be used for injvp
.- Parameters:
in_mat (Tensor) –
out_quaternion (Tensor) –
adj_mat (Tensor) –
- static backward(ctx, grad_out_q)
Defines a formula for differentiating the operation with backward mode automatic differentiation (alias to the vjp function).
This function is to be overridden by all subclasses.
It must accept a context
ctx
as the first argument, followed by as many outputs as theforward
returned (None will be passed in for non tensor outputs of the forward function), and it should return as many tensors, as there were inputs toforward
. Each argument is the gradient w.r.t the given output, and each returned value should be the gradient w.r.t. the corresponding input. If an input is not a Tensor or is a Tensor not requiring grads, you can just pass None as a gradient for that input.The context can be used to retrieve tensors saved during the forward pass. It also has an attribute
ctx.needs_input_grad
as a tuple of booleans representing whether each input needs gradient. E.g.,backward
will havectx.needs_input_grad[0] = True
if the first input toforward
needs gradient computed w.r.t. the output.
- _backward_cls
alias of
MatrixToQuaternionBackward