create Image and Tensor/Storage from parts #208
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request includes several important changes to the
kornia-image
andkornia-tensor
crates. The changes introduce new methods for creating images and tensors from raw parts, add corresponding tests, and improve memory safety checks in deallocation.Needed by: https://github.com/copper-project/copper-rs/pull/193/files
New methods for creating images and tensors from raw parts:
crates/kornia-image/src/image.rs
: Added thefrom_raw_parts
method to theImage
struct, which allows creating an image from raw parts. This method includes safety documentation and argument descriptions.crates/kornia-tensor/src/storage.rs
: Added thefrom_raw_parts
method to theTensorStorage
struct, enabling the creation of tensor storage from raw parts. This method includes safety documentation.crates/kornia-tensor/src/tensor.rs
: Added thefrom_raw_parts
method to theTensor
struct, allowing the creation of a tensor from raw parts. This method includes safety documentation and argument descriptions.Tests for new methods:
crates/kornia-image/src/image.rs
: Added a test for thefrom_raw_parts
method in themod tests
section to ensure the method works correctly.crates/kornia-tensor/src/tensor.rs
: Added a test for thefrom_raw_parts
method in themod tests
section to verify its functionality.Memory safety improvements:
crates/kornia-tensor/src/allocator.rs
: Added a null pointer check before deallocating memory in thedealloc
method of theCpuAllocator
struct to improve memory safety.