How to quickly and efficiently modify the values in NDArray object without matrix operations. #2184
Answered
by
frankfliu
huaizhe2012
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
frankfliu
Nov 25, 2022
Replies: 1 comment 1 reply
-
Java doesn't allow operator override, so you won't be able to use index to modify NDArray. In each operation of NDArray, it actually generates a temporary native NDArray, to avoid OOM, you need to close those temporary resource in each loop manually. Each set/get call in NDArray has JNI call overhead, it's not efficient. You can do calculation in java heap and then set the hold data to NDArray. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
huaizhe2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@huaizhe2012
Java doesn't allow operator override, so you won't be able to use index to modify NDArray.
In each operation of NDArray, it actually generates a temporary native NDArray, to avoid OOM, you need to close those temporary resource in each loop manually.
Each set/get call in NDArray has JNI call overhead, it's not efficient. You can do calculation in java heap and then set the hold data to NDArray.