Comments (10)
Hi @arpit15 ,
Regarding the test_scalar
, you are right, the dot
function will return a float
for which the comparison op will yield a bool
value. On the other hand, Vector1m
is equivalent to mask_t<Array<float, 1>>
in C++. Arrays with 1 dimension are pretty much the same as scalar values like float
. Therefore you should be able to seamlessly do arithmetic between bool
, Mask
, and Vector1m
in python, so no need for explicit cast.
The same applies to the test_cuda
. However this time, the dot
function return a CUDAArray<float>
value (that lives on the GPU), to the operator<
returns a Mask
and not a bool
.
Please let me know if this answered you questions.
from enoki.
I asked the difference in types because I am unable to perform operations between these types. For ex: I tried res = result1 & result2
in test_scalar
and test_gpu
both give me errors.
Error in scalar
TypeError: unsupported operand type(s) for &: 'bool' and 'enoki.scalar.Vector1m'
Error in gpu
TypeError: unsupported operand type(s) for &: 'enoki.cuda.Mask' and 'enoki.cuda.Vector1m
Please let me know the correct way to perform element-wise operations in enoki, if this is not the correct way.
from enoki.
Currently enoki.cuda.Mask
can be implicitly casted to enoki.cuda.Vector1m
but not the other way around. Somehow Python also tries to cast from right to left with the &
operator, which causes your issue. I will try to fix this in the future.
In the meantime, you should be able to do res = result2 & result1
.
Also, could you tell me why using cuda.Vector1f
and not cuda.Float32
? This should solve you issue as well.
from enoki.
Thanks! This issue is solved by using res = result2 & result1
.
I am trying to write custom area emitter in python. My idea was to create a Vector1m
for both scalar and cuda, to write logic like here. I presumed that comparing Vector1f
in both variants would give me Vector1m
which is the type I am observing on the python side when using arguments of sample_direction
function.
Is there a reason to not have implicit converters from scalar.Vector1m
to bool
?
from enoki.
Is there a reason to not have implicit converters from scalar.Vector1m to bool?
No specific reason, we might add it in the future.
In this code
dot(ds.d, ds.n) < 0.f && neq(ds.pdf, 0.f)
both comparisons should return a Mask
. I don't see where the Vector1f
comes in?
from enoki.
I don't really care about using Vector1f
. I am just using it to create Vector1m
. Using neq
in python yields Vector1m
for neq(ds.pdf, 0)
. Therefore using
dot(ds.d, ds.n) < 0.f & neq(ds.pdf, 0.f)
doesn't work. However,
neq(ds.pdf, 0.f) & dot(ds.d, ds.n) < 0.f
works fine, as you suggested.
Is there a way to create Mask
type var from Vector1m
type var without explicitly knowing, if the variant is scalar
or cuda
?
The main source of my problems is friction between Vector1m
and Mask
types.
from enoki.
I see problems due to no implicit conversion from Vector1m
to Mask
when calling m_radiance->eval
in scalar variant as the function requires Mask
aka bool
type. However, processing using neq(ds.pdf, 0.f) & dot(ds.d, ds.n) < 0.f & active
gives me Vector1m
from enoki.
I see your problem now. There was indeed some missing bindings for the scalar mode causing the following issue:
ek.neq(0.0, 0.0) # -> return Vector1m instead of bool
This should be fixed now (486ddb0)
In the other modes (dynamic
, cuda
), I would be surprise if you ever encounter a Vector1m
. This would indicate that there is another bug. Let me know in that case.
from enoki.
Thanks for resolving this error. I tripped over another bug. I don't know if I should make another issue for this.
ek.select(True, 0.1, 0.2)
returns enoki.scalar.Vector1m
with value [1]
which is wrong type and value.
from enoki.
Another one, thanks!
Just fixed in 1cc24d0
from enoki.
Related Issues (20)
- Force enoki::Array<float, 3> to be 12 bytes HOT 4
- [General question] Figuring out the correct index type for `gather` operations HOT 2
- Double precision for Enoki autodiff (not supported yet) HOT 3
- sign documentation is wrong HOT 1
- Using CUDA backend of Enoki in a multithreaded environment HOT 1
- Difference between this enoki and wjakob/enoki HOT 2
- The behavior of enoki::hsum does not correspond to the documentation HOT 5
- Enoki cannot build on VS2019 16.10 HOT 12
- How to use binary_search overloads in python.
- Python ImportError on Windows with enoki.cuda HOT 2
- build issues: undefined reference to `clock_gettime@GLIBC_2.17'
- AMD GPU code generation? HOT 2
- Runtime dynamic dispatch of functions using Enoki? HOT 1
- SYCL support HOT 1
- Error: zero size memory allocation when calling 'cuda_partition' HOT 1
- Enoki does not generate fma instruction for fmadd with Array<float, 1> and Clang
- using enoki with custom matrix class HOT 1
- simple enoki example does not compile with Intel compiler HOT 1
- Vectorized RNG repeats values with nested arrays
- Installation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from enoki.