Replies: 2 comments 1 reply
-
Hi @Dream4Leo,
No, we currently only have Python bindings for With regards to your second question, what you have should work (omitting the slicing operation), although I've only tested this out on Dr.Jit 1.0.1. I suspect you're using an older version of Dr.Jit as the terminology for placeholder variables is outdated. If you're still encountering issues, it might be worth providing a bit more code with regards to how |
Beta Was this translation helpful? Give feedback.
-
It looks like you're working with the Mitsuba 3 rendering framework, which uses the Dr.Jit (Differentiable Runtimes for Just-In-Time Compilation) library for its just-in-time compilation and automatic differentiation capabilities. The error messages you're encountering suggest that there are some specific requirements for constructing Let's address each of your issues:
The If you want to create a import mitsuba as mi
import drjit as dr
# Initialize the spectrum objects
spectrum_real = mi.Spectrum(0)
spectrum_imag = mi.Spectrum(1)
# Convert the spectra to float values
real_part = float(spectrum_real)
imag_part = float(spectrum_imag)
# Create a Complex2f object
complex_value = dr.cuda.Complex2f(real_part, imag_part)
In Dr.Jit, you can use the Here’s an example of how to use import drjit as dr
# Example arrays
a = dr.array([1.0, 2.0, 3.0])
b = dr.array([4.0, 5.0, 6.0])
# Condition: a > 2
condition = a > 2
# Use dr.where to select elements based on the condition
result = dr.where(condition, a, b) # If condition is True, take a, otherwise take b
print(result) # Output: [4.0, 5.0, 3.0]
When working with spectral dimensions, you need to be careful about how you handle the data. The error you encountered suggests that you might be trying to perform operations that are not supported directly on the spectral dimension. To sum over the spectral dimension, you can use the import mitsuba as mi
import drjit as dr
# Initialize the spectral arrays
a = mi.Spectrum([1.0, 2.0, 3.0]) # Example spectral array
b = mi.Spectrum([4.0, 5.0, 6.0]) # Example spectral array
# Expand the dimensions to allow broadcasting
a_expanded = dr.tile(a, (b.size, 1)) # Tile a to match the size of b
b_expanded = dr.tile(b, (a.size, 1)).T # Tile b and transpose to match the shape of a
# Perform the element-wise multiplication and sum over the spectral dimension
result = dr.sum(dr.exp(a_expanded * b_expanded), axis=1)
print(result) Summary
If you have more specific requirements or if these examples don't fully address your needs, please provide more details, and I can help further. |
Beta Was this translation helpful? Give feedback.
-
Is there a way to create python equivalent type of
dr::Complex<UnpolarizedSpectrum>
?I tried
dr.cuda.Complex2f(mi.Spectrum(0), mi.Spectrum(1))
and it says:TypeError: Complex2f constructor expects: 1 or 2 values of type "float", a matching list/tuple, or a NumPy/PyTorch/TF/Jax array.
I am using
cuda_spectral
variant of mitsuba, having searched through docs but could not find a python example.Edit:
I also wonder the correct way in drjit to implement something like
dr.sum(dr.exp(a[:,None]*b), axis=1)
wherea
isSpectrum
andb
is a drjit float array. I tried to manually unroll the spectral dimension likes[0]=dr.sum(dr.exp(a[0]*b))
, but it throws RuntimeError: jitc_var_eval(r3749): placeholder variables are used to record computation symbolically and cannot be scheduled for evaluation.Beta Was this translation helpful? Give feedback.
All reactions