question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Area Select

react-native-pytorch-core (core package)

Description

Hi, thanks for contributions.

How can i flip a tensor like torch.flip? There is no implementation of flip function in Playtorch docs

Another solution i thought is to make a new tensor and assign reversed values using for loop such as the tensor[::, ::-1] . However, i got a result Cannot assign to property ~ My code and the corresponding error are as follows.


CODE: e.g., (.js file)

  let tempTensor = torch.zeros(1);
  console.log('temp value', tempTensor.data());
  console.log('temp shape', tempTensor.shape);
  tempTensor[0].data = 5; //or tempTensor[0]
  console.log('result', tempTensor.data());

ERROR: e.g.,

 LOG  temp value [0]
 LOG  temp shape [1]
 WARN  Possible Unhandled Promise Rejection (id: 10):
Error: Exception in HostObject::set for prop 'data': TypeError: Cannot assign to property 'data' on HostObject with default setter

How can i solve this problem? Many thanks for your help :)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
nh9kcommented, Aug 8, 2022

@raedle, Thank you so much 😄 My app gets a fliped image, so i have to flip image before our models infer this image. In detail, my app will use tensor.permute ([2,1,0]) and flip, because it receives images rotated 90 degrees. I will report back if I have any questions or if this problem is solved.

1reaction
raedlecommented, Aug 9, 2022

Fantastic to hear, @nh9k! I’ll close the issue, then

Read more comments on GitHub >

github_iconTop Results From Across the Web

torch.flip — PyTorch 1.13 documentation
torch.flip ... Reverse the order of a n-D tensor along given axis in dims. ... torch.flip makes a copy of input 's data....
Read more >
How to Reverse Order of Rows in a Tensor - Stack Overflow
According to documentation torch.flip has argument dims , which control what axis to be flipped. In this case torch.flip(tensor_a, ...
Read more >
flip a Tensor · Issue #229 · pytorch/pytorch - GitHub
I've been timing a number of options for flipping a tensor and so far, the fastest on my GPU has been either explicit...
Read more >
tf.reverse | TensorFlow v2.11.0
Given a tensor , and a int32 tensor axis representing the set of dimensions of tensor to reverse. This operation reverses each dimension...
Read more >
Machine Learning — PyTorch - Medium
2. torch.flip(input, dims) ... It reverse the order of a n-D tensor along given axis in dims. It requires two argument, the first...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found