For detach, if the transform callback is called then we know it's a Dr.Jit type
Otherwise, for other types the transform_unknown object is returned which by default is the borrowed reference of the passed-in value
In the case of a scalar Dr.Jit type, we should be performing a copy because otherwise a move will zero-out the original variable (e.g. dr.scalar.Array3f)
The other fix to modify add_generic (CustomOp input/output variables) revolves around a missing corresponding JIT (primal) index being provided
This is a problem for tensors, because apply.cpp::transform checks whether the transformed length of the underlying transformed array matches the original to preserve the original tensor shape
Otherwise, the new tensor is flattened
i.e. we need the JIT index to be there in order to determine the length of the new array
For
detach
, if the transform callback is called then we know it's a Dr.Jit typeOtherwise, for other types the
transform_unknown
object is returned which by default is the borrowed reference of the passed-in valueIn the case of a scalar Dr.Jit type, we should be performing a copy because otherwise a
move
will zero-out the original variable (e.g.dr.scalar.Array3f
)The other fix to modify
add_generic
(CustomOp input/output variables) revolves around a missing corresponding JIT (primal) index being providedThis is a problem for tensors, because
apply.cpp::transform
checks whether the transformed length of the underlying transformed array matches the original to preserve the original tensor shapeOtherwise, the new tensor is flattened
i.e. we need the JIT index to be there in order to determine the length of the new array