Jetson에서 전치한 NumPy 배열을 CUDA 인터페이스에 넘기기 전에 연속 메모리인지 읽는다.
import numpy as np
x = np.arange(12).reshape(3, 4).T
y = np.ascontiguousarray(x)
print(x.flags.c_contiguous, y.flags.c_contiguous)전치 view와 ascontiguousarray() 결과의 flags를 비교한다. shape가 같거나 원소가 같아도 메모리 배치가 같다는 뜻은 아니다.
Python 코드를 example.py로 저장해 python3 example.py로 실행한다. import하는 모듈과 예제에 지정한 입력 파일이 준비돼 있어야 한다.
답글 달기