Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tensor comparison work error under some testdata!!! #36

Open
Xrigok opened this issue Jun 15, 2023 · 3 comments
Open

tensor comparison work error under some testdata!!! #36

Xrigok opened this issue Jun 15, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@Xrigok
Copy link

Xrigok commented Jun 15, 2023

I meet a stranger problem:tensor comparison work error at some test data, other test data is correct, is strange problem
this my code:

import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np

device="ocl:0"
if device.find('ocl')==0:
torch.ops.load_library("../libpt_ocl.so")
device = device.replace('ocl','privateuseone')

y=[5.7657e-05, 11.25,2.2863e-05, 1.5291e-05, 9.2284e-06, 1.2024e-05, 1.1976e-05,1.4908e-05, 1.6296e-05, 1.3599e-05, 1.7960e-05]

im = torch.tensor(y, dtype=torch.float32)
im=im.to(device)
print(im>0.25)

z=[0.1]
im2 = torch.tensor(z, dtype=torch.float32)
print(im2)
print(im2>0.25)
im2=im2.to(device)
print(im2)
print(im2>0.25)

image

@artyom-beilis
Copy link
Owner

I don't understand your example. Can you elaborate?

@Xrigok
Copy link
Author

Xrigok commented Jun 18, 2023

z=[0.1]
im2 = torch.tensor(z, dtype=torch.float32)
print(im2)
now,output im2=》0.1, and im2 device is cpu,
print(im2>0.25)=》False(this output is correct)

Here,we put im2 to opencl device
im2=im2.to(device)
and, we print im2>0.25:
print(im2>0.25)
this output is True,and the output is uncorrrect.
It should to output False
I check the compare kernel and print scale in kernel, w(scale) is 0 of above example

@artyom-beilis
Copy link
Owner

Ok thanks got it!

@artyom-beilis artyom-beilis added the bug Something isn't working label Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants