Closed pira998 closed 1 year ago
Hi @pira998!
Thank you for your pull request and welcome to our community.
In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.
In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.
Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed
. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.
If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!
I think this fix in pytorch3d/implicitron could be made here as well, and that would fix this problem, perhaps more efficiently.
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!
Yes @bottler. I agree that the fix in pytorch3d/implicitron could be a good solution for this problem. Because the iter() function creates an iterator for the array and the zip() function combines the elements of two arrays. It then uses a list comprehension to create a new list of elements, where each element is a tuple containing the corresponding elements of the two arrays. This solution is more efficient in terms of memory usage, as it only creates a single list of tuples.
My solution uses a for loop to iterate through the indices and creates slices of the array using the slice notation. It appends each slice to a new list, which is stored in the vals variable. This solution is more efficient in terms of time complexity, as it does not need to create a new list for every iteration.
vals = []
start = 0
for idx in indices:
vals.append(all_vals_res[start:idx])
start = idx
In terms of which solution is better, it depends on the specific use case and the size of the input array. The first solution is more memory efficient, but the second one is more time efficient. If the size of the input array is large, the second solution is more appropriate. If memory usage is a concern, the first solution is more appropriate. In our case, memory usage is much more important. So I would go with the first solution(yours). thanks.
Fix #60 The cause of this error is that the
all_vals_res
lists contain nested lists or arrays with different shapes. Thenp.split
function only works with 1-D arrays and will raise an error if it encounters a nested list or array with a different shape.