Deprecated
in API level 37
Class Overview
Class of managing Knox AI Session.
Summary
Nested Classes |
enum |
KnoxAiSession.CompUnit |
Deprecated
in API level 37
|
enum |
KnoxAiSession.DataFormat |
Deprecated
in API level 37
|
enum |
KnoxAiSession.DataType |
Deprecated
in API level 37
|
enum |
KnoxAiSession.ExecType |
Deprecated
in API level 37
|
enum |
KnoxAiSession.Mode |
Deprecated
in API level 37
|
enum |
KnoxAiSession.ModelInputType |
Deprecated
in API level 37
|
enum |
KnoxAiSession.ModelType |
Deprecated
in API level 37
|
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
Public Constructors
public
KnoxAiSession
()
Deprecated
in API level 37
Public Methods
Deprecated
in API level 37
Closes the current Knox AI session.
Returns
- Returns status of close() API. Returns 0 on success.
Usage
Called at the end of AI model execution to release the instance of session.
int status = -1;
status = session.close();
|
Permission
com.samsung.android.knox.permission.KNOX_NDA_AI |
Deprecated
in API level 37
Executes the AI model using the given inputs and outputs the result of execution.
Returns
- Returns status of Execute API. Returns 0 on success.
Usage
Called after the session is opened to execute AI model.
DataBuffer[] input = new DataBuffer[1];
DataBuffer[] output = new DataBuffer[1];
DataBuffer dB = new DataBuffer();
dB.setDataType((byte) 0);
dB.setDataFormat((byte) 1);
int[] shape = new int[]{1, 224, 224, 3};
dB.setShape(shape);
dB.setDataSource((byte)2);
try {
SharedMemory sharedMemory = SharedMemory.create("data", indata.length * 4);
ByteBuffer bBuffer = sharedMemory.mapReadWrite();
byte[] bytes = DataBuffer.readFloatToBytes(indata);
bBuffer.put(bytes);
dB.setDataShared(sharedMemory);
} catch (ErrnoException e) {
e.printStackTrace();
}
input[0] = dB;
status = session.execute(input, output);
if (output != null && output.length > 0 ) {
if (output[0].getDataSource() == 0) {
float[] outputData = output[0].getDataOriginal();
}
}
|
Permission
com.samsung.android.knox.permission.KNOX_NDA_AI |
public
KnoxAiManager.ErrorCodes
getModelInputShape
(int inputIndex, int[] shape)
Deprecated
in API level 37
Gets the dimensions of input data based on the AI model.
Returns
- Returns status of getModelInputShape() API. Returns 0 on success.
Usage
Called before execute API to get the expected input dimensions.
int status = -1;
int[] inputShape = new int[4];
status = session.getModelInputShape(0, inputShape);
|
Permission
com.samsung.android.knox.permission.KNOX_NDA_AI |
Deprecated
in API level 37
Opens the Knox AI session and loads the AI model using the given KfaOptions.
Returns
- Returns status of Execute API. Returns 0 on success.
Usage
Called at beginning before AI model execution to load the model.
KfaOptions options = new KfaOptions();
options.setExecType(0);
options.setCompUnit(0);
options.setmType(4);
ArrayList ipNames = new ArrayList();
ipNames.add("keras_layer_input");
options.setInputNames(ipNames);
ArrayList opNames = new ArrayList();
opNames.add("Identity");
options.setOutputNames(opNames);
options.setModelInputType(0);
options.setWeights_file("/data/KFA/converted_model_224.tflite.pkg");
options.setModel_file("/data/KFA/converted_model_224.tflite.pkg");
status = session.open(options);
return status;
|
Permission
com.samsung.android.knox.permission.KNOX_NDA_AI |