C contiguous stride not working for the example #178
-
|
Hi cuquantum team, I am trying to play around with the example python/samples/cutensornet/tensornet_example.py, and I wonder if I can use the C-contiguous arrays for the optimization of contraction paths and also the actual contraction. To do this, I just replaced desc_net = cutn.create_network_descriptor(handle,
num_inputs, num_modes_in, extents_in, strides_in, modes_in, qualifiers_in, # inputs
nmode_R, extent_R, 0, modes_R, # output
data_type, compute_type)with desc_net = cutn.create_network_descriptor(handle,
num_inputs, num_modes_in, extents_in, strides_in, modes_in, qualifiers_in, # inputs
nmode_R, extent_R, R_d.strides, modes_R, # output
# nmode_R, extent_R, 0, modes_R, # output
data_type, compute_type)and didn't change any other thing. However, the output is: Could you tell me what happened here or how can I use C-contiguous arrays in this example instead of F-contiguous? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
|
Hello, cuTensorNet does support C-contiguous arrays and there are a few misses in your current approach.
strides_in = [[s // o.itemsize for s in o.strides] for o in (A_d, B_d, C_d, D_d)]One more question, is there any particular reason why you're not using our pythonic API |
Beta Was this translation helpful? Give feedback.
Hello,
cuTensorNet does support C-contiguous arrays and there are a few misses in your current approach.
cupy.ndarraysin the script, therefore theA_d.stridesin your change is only of size one, not corresponding to the fulll ndarray, at the top, you would need to docp.random.random((np.prod(extent_A),), dtype=np.float32).reshape(extent_A)such thatA_d.stridesis of the correct size. This is needed for all input/output arrays for generic strides support.cupy.ndarray.stridesis scaled by the element items, therefore, strides_in needs to be modified with below, same for the strides specifica…