Proper error handling in the native code and Java wrapper.#10
Conversation
Created base ArrayFire class that loads ArrayFire.
Moved allocate and createEmptyArray from Data to constructors in Array Renamed THROWS macro to AF_CHECK
umar456
left a comment
There was a problem hiding this comment.
Super excited about this update. I know you are still working on updating the API. Made a couple of notes that can be addressed in the future.
|
|
||
| static { | ||
| @SuppressWarnings("serial") | ||
| final Map<Integer, String> map = new HashMap<>() { |
There was a problem hiding this comment.
Switch would be better here don't you think?
| dim_t dims[4]; \ | ||
| af_dtype ty = f32; \ | ||
| AF_CHECK(af_get_dims(dims + 0, dims + 1, dims + 2, dims + 3, ARRAY(a))); \ | ||
| AF_CHECK(af_get_type(&ty, ARRAY(a))); \ |
There was a problem hiding this comment.
This sounds strange. I thought ArrayFire could handle this internally. Looks like its there from earlier and its formatted.
| Array C = new Array(); | ||
|
|
||
| // Do vector addition on the device | ||
| Arith.add(C, A, B); |
There was a problem hiding this comment.
Its going to be difficult to figure out where each of the functions are defined. I think it may be better to put everything in the ArrayFire class instead of in these other classes.
There was a problem hiding this comment.
I was thinking that too. You basically have to guess which class the method would be in
af_err > 0, the native code throws aJavaExceptioncontaining the error code, message, and and the stack trace including the native code.ArrayFireExceptionpresent in the Java wrapper.HelloWorldexample