K iVddlZddlmZddlZddlZddlZddlmZejjZ ejdZ dZdZdZeejj#dej$d fej&d fej(d fej*d fej,d fej.dfej0dfej2dfej4dfej6dfej8dfg dZeejj#de j$e j&e j(e j*e j,e j.e j0e j2e j4e j6e j8g dZdZdZ y)Nwraps)Versionnumpycntjjtj||dk(S)N)ctypes pythonapiPyCapsule_IsValid py_object)capsulenames _/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pyarrow/tests/test_dlpack.pyr r s,    - -f.>.>w.G NRS SSc|j}t|ddusJtj|}tjj ||d|j dk(sJy)NsdltensorT)strict)rr) __dlpack__r np from_dlpacktestingassert_array_equal__dlpack_device__)arr expected_arrDLTensorresults rcheck_dlpack_exportr$sa~~H X{ 3t ;; ; ^^C FJJ!!&,t!D  "f ,, ,rc.tfd}|S)Nctjtj} |i|tj|k(sJS#tj|k(sJwxYw)N)gccollectpatotal_allocated_bytes)argskwargsallocated_bytesfs rwrapperz&check_bytes_allocated..wrapper/s\ 224 Ad%f%++-@ @@2++-@ @@s A A'r)r'r(s` rcheck_bytes_allocatedr).s" 1XAA Nr) value_type np_type_struint8uint16uint32uint64int8int16int32int64float16float32float64cttjtdkrtjdtj gdtj |}tj ||}t||tjj|}t|||jdd}tj dgtj |}t|||jdd}tj dgtj |}t|||jd}tj dd gtj |}t||tj g|}tj gtj |}t||tjj|}t||y) N1.24.0yNo dlpack support in numpy versions older than 1.22.0, strict keyword in assert_array_equal added in numpy version 1.24.0rdtypetyperr;rr<) rr __version__pytestskiparrayr>r"rTensor from_numpyslice)r*r+expectedrt arr_slicedarr_zeros r test_dlpackrL:su$r~~!22  xx +)>x?H ((8* -CX& X&A8$1aJxx288K#8x9H H-1aJxx288K#8x9H H-1JxxAbhh{&;xG %F/2F;>G Gctjd}tjtjdtj g}tj gdtj }tj|g|}|j||jd}|j||j}|d}tjtd5tj|dddtjtd5|jdddy#1swY>xYw#1swYyxYw) Nz pyarrow.cudaf0r:r?)schemarz=DLPack support is implemented only for buffers on CPU device.rX)rB importorskipr"r`fieldr1rD record_batchserialize_record_batchContextread_record_batchrZNotImplementedErrorrrr)cudar`a0batchcbufcbatchcarrs rtest_dlpack_cuda_not_supportedrns   ~ .D YYrxxz23 4F )"((* -B OORD 0E  & &udll1o >D  # #D%,, 7F $rvs$ ,[[   V!T- ! W h h h F W W W y! y! y!  %!"%B((BIIryy"))''288RXXrxx**bjj"**?@ % @ % 6!r