ailia  1.3.0.0
Public Member Functions | Protected Member Functions | Protected Attributes | Properties | List of all members
AiliaModel Class Reference
Inheritance diagram for AiliaModel:
Inheritance graph
[legend]
Collaboration diagram for AiliaModel:
Collaboration graph
[legend]

Public Member Functions

bool Environment (int type)
 Selects the specified type of calculation environment. More...
 
string EnvironmentName ()
 Displays the name of the selected environment. More...
 
int GetEnvironmentCount ()
 Get the number of available computing environments (CPU, GPU). More...
 
Ailia.AILIAEnvironment GetEnvironment (int idx)
 Obtains the computing environment for the specified index. More...
 
bool SelectEnvironment (int idx)
 Select the calculation environment. More...
 
Ailia.AILIAEnvironment GetSelectedEnvironment ()
 Retrieves the selected computing environment. More...
 
void SetMemoryMode (uint set_memory_mode)
 Sets the memory mode. More...
 
void DisableLayerFusion ()
 Disables speedup due to layer fusion. More...
 
virtual bool OpenFile (string prototxt_path, string model_path)
 Create a network object from a model file. More...
 
virtual bool OpenMem (byte[] prototxt_buf, byte[] model_buf)
 Creates network objects from memory. More...
 
virtual bool OpenEx (Ailia.ailiaFileCallback callback, IntPtr arg1, IntPtr arg2)
 Creates a network object from a file callback. More...
 
bool Predict (float[] output_data, float[] input_data)
 Perform inference and obtain inference results. More...
 
Ailia.AILIAShape GetInputShape ()
 
uint [] GetInputShapeND ()
 Obtains the shape of the input data at the time of inference. More...
 
bool SetInputShape (Ailia.AILIAShape shape)
 Sets the shape of the input data during inference. More...
 
bool SetInputShapeND (uint[] shape, int dim)
 Change the shape of the input data during inference. More...
 
Ailia.AILIAShape GetOutputShape ()
 Obtains the shape of the output data during inference. More...
 
uint [] GetOutputShapeND ()
 Obtains the shape of the output data during inference. More...
 
Ailia.AILIAShape GetBlobShape (string layer_name)
 Obtains the shape (layer format) of the internal data (Blob) at the time of inference. (Obsolete) More...
 
int FindBlobIndexByName (string name)
 Look up and retrieve the index of the internal data (Blob) at the time of inference by name. More...
 
Ailia.AILIAShape GetBlobShape (uint idx)
 Obtains the shape (layer format) of the internal data (Blob) at the time of inference. More...
 
Ailia.AILIAShape GetBlobShape (int idx)
 
bool GetBlobData (float[] output_data, uint idx)
 Obtains internal data (Blob) at the time of inference. More...
 
bool GetBlobData (float[] output_data, int idx)
 
bool SetInputBlobData (float[] input_data, uint idx)
 Set input data to the specified Blob. More...
 
bool SetInputBlobData (float[] input_data, int idx)
 
bool SetInputBlobShape (Ailia.AILIAShape shape, uint idx)
 Sets the format of the specified input data (Blob). (4 dimensions or less) More...
 
bool SetInputBlobShape (Ailia.AILIAShape shape, int idx)
 
bool SetInputBlobShapeND (uint[] shape, uint dim, uint idx)
 Sets the format of the input data (Blob). (5D or more) More...
 
bool SetInputBlobShapeND (uint[] shape, int dim, int idx)
 
uint [] GetInputBlobList ()
 Obtains a list of the indices of the input data (Blob). More...
 
uint [] GetOutputBlobList ()
 Obtains a list of indices of the output data (Blob). More...
 
bool CopyBlobData (uint dst_blob_idx, uint src_blob_idx, AiliaModel src_model=null)
 Perform copies between blobs that specified. More...
 
bool Update ()
 Inference is performed with pre-populated data. More...
 
virtual void Close ()
 Destroys network objects. More...
 
virtual void Dispose ()
 Release resources. More...
 
string GetStatusString (int status)
 Returns a string corresponding to the status code. More...
 
string GetErrorDetail ()
 Returns error details. More...
 
bool SetProfileMode (uint profile_mode)
 Enable profile mode. More...
 
string GetSummary ()
 Obtain network information and profile results. More...
 

Protected Member Functions

virtual void Dispose (bool disposing)
 

Protected Attributes

IntPtr ailia = IntPtr.Zero
 
bool logging = true
 

Properties

int Status [get, protected set]
 Status code Get the library status code. More...
 

Member Function Documentation

◆ Close()

virtual void AiliaModel.Close ( )
inlinevirtual

Destroys network objects.

Destroys and initializes the network object.

Reimplemented in AiliaPoseEstimatorModel, AiliaDetectorModel, AiliaFeatureExtractorModel, and AiliaClassifierModel.

1528  {
1529  if (ailia != IntPtr.Zero)
1530  {
1532  ailia = IntPtr.Zero;
1533  }
1534  }
Definition: Ailia.cs:20
static void ailiaDestroy(IntPtr net)
destroy network object *
IntPtr ailia
Definition: AiliaModel.cs:24

◆ CopyBlobData()

bool AiliaModel.CopyBlobData ( uint  dst_blob_idx,
uint  src_blob_idx,
AiliaModel  src_model = null 
)
inline

Perform copies between blobs that specified.

Parameters
dst_blob_idxThe index of destination blob
src_blob_idxThe index of source blob
src_mdoelThe model object that contains source blob. If specify null, perform copy blob inner this model object.
Returns
Returns true on success, false on failure.
1458  {
1459  IntPtr src_ailia = ailia;
1460  if (src_model != null) src_ailia = src_model.ailia;
1461  if (ailia == IntPtr.Zero || src_ailia == IntPtr.Zero) return false;
1462 
1463  int status = Status = Ailia.ailiaCopyBlobData(ailia, dst_blob_idx, src_ailia, src_blob_idx);
1464  if (status != Ailia.AILIA_STATUS_SUCCESS)
1465  {
1466  if (logging)
1467  {
1468  Debug.Log("ailiaUpdate failed " + status + " (" + GetStatusString(status) + ")");
1469  }
1470  return false;
1471  }
1472  return true;
1473  }
bool logging
Definition: AiliaModel.cs:32
static int ailiaCopyBlobData(IntPtr dst_net, UInt32 dst_blob_idx, IntPtr src_net, UInt32 src_blob_idx)
Perform copies between blobs that specified.
Definition: Ailia.cs:20
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
IntPtr ailia
Definition: AiliaModel.cs:24

◆ DisableLayerFusion()

void AiliaModel.DisableLayerFusion ( )
inline

Disables speedup due to layer fusion.

Disables speedup due to layer fusion. Default is enabled.

357  {
358  disalbe_layer_fusion = true;
359  }

◆ Dispose() [1/2]

virtual void AiliaModel.Dispose ( )
inlinevirtual

Release resources.

Reimplemented in AiliaPoseEstimatorModel, AiliaDetectorModel, AiliaFeatureExtractorModel, and AiliaClassifierModel.

1544  {
1545  Dispose(true);
1546  }
virtual void Dispose()
Release resources.
Definition: AiliaModel.cs:1543

◆ Dispose() [2/2]

virtual void AiliaModel.Dispose ( bool  disposing)
inlineprotectedvirtual

Reimplemented in AiliaPoseEstimatorModel, AiliaDetectorModel, AiliaFeatureExtractorModel, and AiliaClassifierModel.

1549  {
1550  if (disposing){
1551  // release managed resource
1552  }
1553  Close(); // release unmanaged resource
1554  }
virtual void Close()
Destroys network objects.
Definition: AiliaModel.cs:1527

◆ Environment()

bool AiliaModel.Environment ( int  type)
inline

Selects the specified type of calculation environment.

環境選択(簡易)

Parameters
typeType of environment ( AILIA_ENVIRONMENT_TYPE_CPU or BLAS or GPU)
Returns
Returns true on success, false on failure.

Simply select the calculation environment from the environment type. To explicitly specify the computing environment, use GetEnvironmentCount(), GetEnvironment(), and SelectEnvironment().

56  {
57  int count = GetEnvironmentCount();
58  if (count == -1)
59  {
60  return false;
61  }
62 
63  for (int i = 0; i < count; i++)
64  {
66  if (env == null)
67  {
68  return false;
69  }
70 
71  if (env.type == type)
72  {
73  if (!SelectEnvironment(i))
74  {
75  return false;
76  }
78  {
79  return true; //優先
80  }
81  }
82  }
83  return true;
84  }
const int AILIA_ENVIRONMENT_BACKEND_VULKAN
Definition: Ailia.cs:1233
bool SelectEnvironment(int idx)
Select the calculation environment.
Definition: AiliaModel.cs:193
Definition: Ailia.cs:20
int GetEnvironmentCount()
Get the number of available computing environments (CPU, GPU).
Definition: AiliaModel.cs:123
Ailia.AILIAEnvironment GetEnvironment(int idx)
Obtains the computing environment for the specified index.
Definition: AiliaModel.cs:156
const int AILIA_ENVIRONMENT_BACKEND_CUDA
Definition: Ailia.cs:1231
Definition: Ailia.cs:1254

◆ EnvironmentName()

string AiliaModel.EnvironmentName ( )
inline

Displays the name of the selected environment.

Returns
Selected Environment Name

Returns the name of the selected environment.

102  {
103  return env_name;
104  }

◆ FindBlobIndexByName()

int AiliaModel.FindBlobIndexByName ( string  name)
inline

Look up and retrieve the index of the internal data (Blob) at the time of inference by name.

Parameters
layer_nameBlob name to search
Returns
Returns the index of the Blob specified by name on success, -1 otherwise.

Ailia.ailiaFindBlobIndexByName() searches for and retrieves the index of the internal data (Blob) at the time of inference by name.

1039  {
1040  uint idx = 0;
1041  int status = Status = Ailia.ailiaFindBlobIndexByName(ailia, ref idx, name);
1042  if (status != Ailia.AILIA_STATUS_SUCCESS)
1043  {
1044  if (logging)
1045  {
1046  Debug.Log("FindBlobIndexByName failed " + status + " (" + GetStatusString(status) + ")");
1047  }
1048  return -1;
1049  }
1050  return (int)idx;
1051  }
bool logging
Definition: AiliaModel.cs:32
Definition: Ailia.cs:20
static int ailiaFindBlobIndexByName(IntPtr net, ref UInt32 blob_idx, string name)
Find and get the index of the internal data (Blob) at inference time by name.
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
IntPtr ailia
Definition: AiliaModel.cs:24

◆ GetBlobData() [1/2]

bool AiliaModel.GetBlobData ( float []  output_data,
uint  idx 
)
inline

Obtains internal data (Blob) at the time of inference.

Parameters
output_dataWhere to export inference results
idxIndex of Blob (0 to ailiaGetBlobCount() -1)
Returns
Returns true on success, false on failure.

Ailia.ailiaGetBlobData() to get the internal data (Blob) at the time of inference. If the inference has never been performed, it fails.

1129  {
1130  if (ailia == IntPtr.Zero)
1131  {
1132  return false;
1133  }
1134 
1135  GCHandle output_buf_handle = GCHandle.Alloc(output_data, GCHandleType.Pinned);
1136  IntPtr output_buf_ptr = output_buf_handle.AddrOfPinnedObject();
1137  int status = Status = Ailia.ailiaGetBlobData(ailia, output_buf_ptr, (uint)(output_data.Length * 4), idx);
1138  output_buf_handle.Free();
1139 
1140  if (status != Ailia.AILIA_STATUS_SUCCESS)
1141  {
1142  if (logging)
1143  {
1144  Debug.Log("ailiaGetBlobData failed " + status + " (" + GetStatusString(status) + ")");
1145  }
1146  return false;
1147  }
1148  return true;
1149  }
bool logging
Definition: AiliaModel.cs:32
static int ailiaGetBlobData(IntPtr net, IntPtr dest, UInt32 dest_size, UInt32 blob_idx)
Get internal data (Blob) at inference time.
Definition: Ailia.cs:20
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
IntPtr ailia
Definition: AiliaModel.cs:24

◆ GetBlobData() [2/2]

public bool AiliaModel.GetBlobData ( float []  output_data,
int  idx 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

1159  {
1160  if (idx < 0)
1161  {
1162  return false;
1163  }
1164  return GetBlobData(output_data, (uint)idx);
1165  }
bool GetBlobData(float[] output_data, uint idx)
Obtains internal data (Blob) at the time of inference.
Definition: AiliaModel.cs:1128

◆ GetBlobShape() [1/3]

Ailia.AILIAShape AiliaModel.GetBlobShape ( string  layer_name)
inline

Obtains the shape (layer format) of the internal data (Blob) at the time of inference. (Obsolete)

Parameters
layer_nameBlob name to search
Returns
If successful, return the shape of the Blob specified by name, otherwise null.

Ailia.ailiaFindBlobIndexByName() to get the index of a Blob from the Blob name. Ailia.ailiaGetBlobShape() obtains the shape (layer format) of the internal data (Blob) at the time of inference and stores it in shape.

993  {
994  if (ailia == IntPtr.Zero)
995  {
996  return null;
997  }
998  Ailia.AILIAShape shape = new Ailia.AILIAShape();
999  uint id = 0;
1000  int status = Status = Ailia.ailiaFindBlobIndexByName(ailia, ref id, layer_name);
1001  if (status != Ailia.AILIA_STATUS_SUCCESS)
1002  {
1003  if (logging)
1004  {
1005  Debug.Log("ailiaFindBlobIndexByName failed " + status + " (" + GetStatusString(status) + ")");
1006  }
1007  return null;
1008  }
1009  status = Status = Ailia.ailiaGetBlobShape(ailia, shape, id, Ailia.AILIA_SHAPE_VERSION);
1010  if (status != Ailia.AILIA_STATUS_SUCCESS)
1011  {
1012  if (logging)
1013  {
1014  Debug.Log("ailiaGetBlobShape failed " + status + " (" + GetStatusString(status) + ")");
1015  }
1016  return null;
1017  }
1018  return shape;
1019  }
bool logging
Definition: AiliaModel.cs:32
const Int32 AILIA_SHAPE_VERSION
Definition: Ailia.cs:310
Definition: Ailia.cs:20
static int ailiaFindBlobIndexByName(IntPtr net, ref UInt32 blob_idx, string name)
Find and get the index of the internal data (Blob) at inference time by name.
Definition: Ailia.cs:313
static int ailiaGetBlobShape(IntPtr net, [In, Out] AILIAShape shape, UInt32 blob_idx, UInt32 version)
Get the shape of the internal data (Blob) at the time of inference.
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
IntPtr ailia
Definition: AiliaModel.cs:24

◆ GetBlobShape() [2/3]

Ailia.AILIAShape AiliaModel.GetBlobShape ( uint  idx)
inline

Obtains the shape (layer format) of the internal data (Blob) at the time of inference.

Parameters
idxIndex of Blob
Returns
If successful, return the shape of the Blob specified by name, otherwise null.

Ailia.ailiaGetBlobShape() obtains the shape (layer format) of the internal data (Blob) at the time of inference and stores it in shape.

1072  {
1073  if (ailia == IntPtr.Zero)
1074  {
1075  return null;
1076  }
1077 
1078  Ailia.AILIAShape shape = new Ailia.AILIAShape();
1079  int status = Status = Ailia.ailiaGetBlobShape(ailia, shape, idx, Ailia.AILIA_SHAPE_VERSION);
1080  if (status != Ailia.AILIA_STATUS_SUCCESS)
1081  {
1082  if (logging)
1083  {
1084  Debug.Log("ailiaGetBlobShape failed " + status + " (" + GetStatusString(status) + ")");
1085  }
1086  return null;
1087  }
1088  return shape;
1089  }
bool logging
Definition: AiliaModel.cs:32
const Int32 AILIA_SHAPE_VERSION
Definition: Ailia.cs:310
Definition: Ailia.cs:20
Definition: Ailia.cs:313
static int ailiaGetBlobShape(IntPtr net, [In, Out] AILIAShape shape, UInt32 blob_idx, UInt32 version)
Get the shape of the internal data (Blob) at the time of inference.
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
IntPtr ailia
Definition: AiliaModel.cs:24

◆ GetBlobShape() [3/3]

public Ailia AILIAShape AiliaModel.GetBlobShape ( int  idx)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

1099  {
1100  if (idx < 0)
1101  {
1102  return null;
1103  }
1104  return GetBlobShape((uint)idx);
1105  }
Ailia.AILIAShape GetBlobShape(string layer_name)
Obtains the shape (layer format) of the internal data (Blob) at the time of inference. (Obsolete)
Definition: AiliaModel.cs:992

◆ GetEnvironment()

Ailia.AILIAEnvironment AiliaModel.GetEnvironment ( int  idx)
inline

Obtains the computing environment for the specified index.

Parameters
idxIndex of Environmental Information (0~ ailiaGetEnvironmentCount() -1)
Returns
Returns the available environment on success or null on failure.

Obtains detailed information about the specified computing environment.

157  {
158  IntPtr env_ptr = IntPtr.Zero;
159  int status = Status = Ailia.ailiaGetEnvironment(ref env_ptr, (uint)idx, Ailia.AILIA_ENVIRONMENT_VERSION);
160  if (status != Ailia.AILIA_STATUS_SUCCESS)
161  {
162  if (logging)
163  {
164  Debug.Log("ailiaGetEnvironment failed " + status + " (" + GetStatusString(status) + ")");
165  }
166  return null;
167  }
168  Ailia.AILIAEnvironment env = (Ailia.AILIAEnvironment)Marshal.PtrToStructure(env_ptr, typeof(Ailia.AILIAEnvironment));
169  if (logging)
170  {
171  //Debug.Log("ENV id:"+env.id+", name:"+Marshal.PtrToStringAnsi(env.name)+", type:"+env.type);
172  }
173  return env;
174  }
bool logging
Definition: AiliaModel.cs:32
Definition: Ailia.cs:20
static int ailiaGetEnvironment(ref IntPtr env, UInt32 env_idx, UInt32 version)
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
const int AILIA_ENVIRONMENT_VERSION
Definition: Ailia.cs:1223
Definition: Ailia.cs:1254

◆ GetEnvironmentCount()

int AiliaModel.GetEnvironmentCount ( )
inline

Get the number of available computing environments (CPU, GPU).

環境選択(詳細)

Returns
Returns the number of available environments on success, -1 on failure. 

Get the number of available environments.

124  {
125  SetTemporaryCachePath();
126  int count = 0;
127  int status = Status = Ailia.ailiaGetEnvironmentCount(ref count);
128  if (status != Ailia.AILIA_STATUS_SUCCESS)
129  {
130  if (logging)
131  {
132  Debug.Log("ailiaGetEnvironmentCount failed " + status + " (" + GetStatusString(status) + ")");
133  }
134  return -1;
135  }
136  return count;
137  }
bool logging
Definition: AiliaModel.cs:32
static int ailiaGetEnvironmentCount(ref Int32 env_count)
Get the number of available computing environments (CPU, GPU)
Definition: Ailia.cs:20
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34

◆ GetErrorDetail()

string AiliaModel.GetErrorDetail ( )
inline

Returns error details.

Returns
Returns a string with error details on success. Returns the error details as a string.
1602  {
1603  return Marshal.PtrToStringAnsi(Ailia.ailiaGetErrorDetail(ailia));
1604  }
static IntPtr ailiaGetErrorDetail(IntPtr net)
Returns error details.
Definition: Ailia.cs:20
IntPtr ailia
Definition: AiliaModel.cs:24

◆ GetInputBlobList()

uint [] AiliaModel.GetInputBlobList ( )
inline

Obtains a list of the indices of the input data (Blob).

Returns
Returns a list of input data (Blob) on success or null on failure. Ailia.ailiaGetInputBlobCount() to get the number of input data (Blob) as count Ailia.ailiaGetBlobIndexByInputIndex() to get the index of the Blob as idx and create a list.
1366  {
1367  if (ailia == IntPtr.Zero)
1368  {
1369  return null;
1370  }
1371 
1372  uint count = 0;
1373  int status = Status = Ailia.ailiaGetInputBlobCount(ailia, ref count);
1374  if (status != Ailia.AILIA_STATUS_SUCCESS || count == 0)
1375  {
1376  return null;
1377  }
1378 
1379  uint[] r = new uint[count];
1380  for (uint i = 0; i < count; i++)
1381  {
1382  uint idx = 0;
1383  status = Status = Ailia.ailiaGetBlobIndexByInputIndex(ailia, ref idx, i);
1384  if (status != Ailia.AILIA_STATUS_SUCCESS)
1385  {
1386  break;
1387  }
1388  r[i] = idx;
1389  }
1390 
1391  return r;
1392  }
Definition: Ailia.cs:20
static int ailiaGetInputBlobCount(IntPtr net, ref UInt32 input_blob_count)
Get the number of input data (Blob).
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
IntPtr ailia
Definition: AiliaModel.cs:24
static int ailiaGetBlobIndexByInputIndex(IntPtr net, ref UInt32 blob_idx, UInt32 input_blob_idx)
Get the index of the input data (Blob)

◆ GetInputShape()

Ailia.AILIAShape AiliaModel.GetInputShape ( )
inline
739  {
740  Ailia.AILIAShape shape = new Ailia.AILIAShape();
742  if (status != Ailia.AILIA_STATUS_SUCCESS)
743  {
744  if (logging)
745  {
746  Debug.Log("ailiaGetInputShape failed " + status + " (" + GetStatusString(status) + ")");
747  }
748  return null;
749  }
750  return shape;
751  }
bool logging
Definition: AiliaModel.cs:32
static int ailiaGetInputShape(IntPtr net, [In, Out] AILIAShape shape, UInt32 version)
Get the shape of the input data during inference.
const Int32 AILIA_SHAPE_VERSION
Definition: Ailia.cs:310
Definition: Ailia.cs:20
Definition: Ailia.cs:313
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
IntPtr ailia
Definition: AiliaModel.cs:24

◆ GetInputShapeND()

uint [] AiliaModel.GetInputShapeND ( )
inline

Obtains the shape of the input data at the time of inference.

Returns
If successful, an array containing the size of each dimension of the input data is returned. shape Otherwise, null is returned. AILIA.ailiaGetInputDim() is used to obtain the dimension of the input data during inference. AILIA.ailiaGetInputShapeND() is used to obtain the shape of the input data at the time of inference. If the shape has more than 5 dimensions, use GetInputShapeND(). If a part of the shape is not yet determined, the value of the corresponding dimension is set to 0, and valid values for the other dimensions are stored in shape. In case of failure, a corresponding error message will be displayed.
778  {
779  uint dim = 0;
780  int status = Status = Ailia.ailiaGetInputDim(ailia, ref dim);
781  if (status != Ailia.AILIA_STATUS_SUCCESS)
782  {
783  if (logging)
784  {
785  Debug.Log("ailiaGetInputDim failed " + status + " (" + GetStatusString(status) + ")");
786  }
787  return null;
788  }
789  uint[] shape = new uint[dim];
790  status = Status = Ailia.ailiaGetInputShapeND(ailia, shape, dim);
791  if (status != Ailia.AILIA_STATUS_SUCCESS)
792  {
793  if (logging)
794  {
795  Debug.Log("ailiaGetInputShapeND failed " + status + " (" + GetStatusString(status) + ")");
796  }
797  return null;
798  }
799  return shape;
800  }
bool logging
Definition: AiliaModel.cs:32
Definition: Ailia.cs:20
static int ailiaGetInputDim(IntPtr net, ref UInt32 dim)
Get the dimension of the input data during inference.
static int ailiaGetInputShapeND(IntPtr net, UInt32[] shape, UInt32 dim)
Get the shape of the input data during inference.
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
IntPtr ailia
Definition: AiliaModel.cs:24

◆ GetOutputBlobList()

uint [] AiliaModel.GetOutputBlobList ( )
inline

Obtains a list of indices of the output data (Blob).

Returns
Returns a list of input data (Blob) on success or null on failure. Ailia.ailiaGetInputBlobCount() to get the number of output data (Blob) as count. Ailia.ailiaGetBlobIndexByInputIndex() to get the index of the Blob as idx and create a list.
1412  {
1413  if (ailia == IntPtr.Zero)
1414  {
1415  return null;
1416  }
1417 
1418  uint count = 0;
1419  int status = Status = Ailia.ailiaGetOutputBlobCount(ailia, ref count);
1420  if (status != Ailia.AILIA_STATUS_SUCCESS || count == 0)
1421  {
1422  return null;
1423  }
1424 
1425  uint[] r = new uint[count];
1426  for (uint i = 0; i < count; i++)
1427  {
1428  uint idx = 0;
1429  status = Status = Ailia.ailiaGetBlobIndexByOutputIndex(ailia, ref idx, i);
1430  if (status != Ailia.AILIA_STATUS_SUCCESS)
1431  {
1432  break;
1433  }
1434  r[i] = idx;
1435  }
1436  return r;
1437  }
Definition: Ailia.cs:20
static int ailiaGetOutputBlobCount(IntPtr net, ref UInt32 output_blob_count)
Get the number of output data (Blob).
static int ailiaGetBlobIndexByOutputIndex(IntPtr net, ref UInt32 blob_idx, UInt32 output_blob_idx)
get index of output data (Blob)
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
IntPtr ailia
Definition: AiliaModel.cs:24

◆ GetOutputShape()

Ailia.AILIAShape AiliaModel.GetOutputShape ( )
inline

Obtains the shape of the output data during inference.

Returns
Return shape on success, null otherwise.

Ailia.ailiaGetOutputShape() to get the shape of the output data during inference. If the shape has more than 5 dimensions, use GetOutputShapeND().

911  {
912  if (ailia == IntPtr.Zero)
913  {
914  return null;
915  }
916  Ailia.AILIAShape shape = new Ailia.AILIAShape();
918  if (status != Ailia.AILIA_STATUS_SUCCESS)
919  {
920  if (logging)
921  {
922  Debug.Log("ailiaGetOutputShape failed " + status + " (" + GetStatusString(status) + ")");
923  }
924  return null;
925  }
926  return shape;
927  }
bool logging
Definition: AiliaModel.cs:32
const Int32 AILIA_SHAPE_VERSION
Definition: Ailia.cs:310
Definition: Ailia.cs:20
Definition: Ailia.cs:313
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
IntPtr ailia
Definition: AiliaModel.cs:24
static int ailiaGetOutputShape(IntPtr net, [In, Out] AILIAShape shape, UInt32 version)
Get the shape of the output data during inference and training.

◆ GetOutputShapeND()

uint [] AiliaModel.GetOutputShapeND ( )
inline

Obtains the shape of the output data during inference.

Returns
Ifsccessful, return shape, otheerwise null.

Get the dimension of the output data during inference with ailiaGetOutputDim(). Ailia.ailiaGetOutputShapeND() to get the shape of the output data during inference.

947  {
948  uint dim = 0;
949  int status = Status = Ailia.ailiaGetOutputDim(ailia, ref dim);
950  if (status != Ailia.AILIA_STATUS_SUCCESS)
951  {
952  if (logging)
953  {
954  Debug.Log("ailiaGetOutputDim failed " + status + " (" + GetStatusString(status) + ")");
955  }
956  return null;
957  }
958  uint[] shape = new uint[dim];
959  status = Status = Ailia.ailiaGetOutputShapeND(ailia, shape, dim);
960  if (status != Ailia.AILIA_STATUS_SUCCESS)
961  {
962  if (logging)
963  {
964  Debug.Log("ailiaGetOutputShapeND failed " + status + " (" + GetStatusString(status) + ")");
965  }
966  return null;
967  }
968  return shape;
969  }
bool logging
Definition: AiliaModel.cs:32
Definition: Ailia.cs:20
static int ailiaGetOutputDim(IntPtr net, ref UInt32 dim)
Get the dimension of the output data during inference.
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
IntPtr ailia
Definition: AiliaModel.cs:24
static int ailiaGetOutputShapeND(IntPtr net, UInt32 [] shape, UInt32 dim)
Get the shape of the output data during inference.

◆ GetSelectedEnvironment()

Ailia.AILIAEnvironment AiliaModel.GetSelectedEnvironment ( )
inline

Retrieves the selected computing environment.

Returns
Returns computed environment information on success or null on failure.

Retrieves detailed information about the selected calculation environment.

221  {
222  IntPtr env_ptr = IntPtr.Zero;
224  if (status != Ailia.AILIA_STATUS_SUCCESS)
225  {
226  if (logging)
227  {
228  Debug.Log("ailiaGetSelectedEnvironment failed " + status + " (" + GetStatusString(status) + ")");
229  }
230  return null;
231  }
232  Ailia.AILIAEnvironment env = (Ailia.AILIAEnvironment)Marshal.PtrToStructure(env_ptr, typeof(Ailia.AILIAEnvironment));
233  return env;
234  }
bool logging
Definition: AiliaModel.cs:32
Definition: Ailia.cs:20
static int ailiaGetSelectedEnvironment(IntPtr net, ref IntPtr env, UInt32 version)
Get the selected computing environment.
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
IntPtr ailia
Definition: AiliaModel.cs:24
const int AILIA_ENVIRONMENT_VERSION
Definition: Ailia.cs:1223
Definition: Ailia.cs:1254

◆ GetStatusString()

string AiliaModel.GetStatusString ( int  status)
inline

Returns a string corresponding to the status code.

  • Parameters
    statusStatus code
    Returns
    Returns a string with error details on success. Returns the error details corresponding to the status code as a string.
1581  {
1582  return Marshal.PtrToStringAnsi(Ailia.ailiaGetStatusString(status));
1583  }
Definition: Ailia.cs:20
static IntPtr ailiaGetStatusString(Int32 status)
Returns a string describing the status code.

◆ GetSummary()

string AiliaModel.GetSummary ( )
inline

Obtain network information and profile results.

Returns
Returns an ASCII string displaying the network information and profile results on success, or null on failure. Obtains a string containing network information and profile results.
1668  {
1669  uint buffer_size = 0;
1670  int status = Status = Ailia.ailiaGetSummaryLength(ailia, ref buffer_size);
1671  if (status != Ailia.AILIA_STATUS_SUCCESS)
1672  {
1673  if (logging)
1674  {
1675  Debug.Log("ailiaGetSummaryLength failed " + status + " (" + GetStatusString(status) + ")");
1676  }
1677  return null;
1678  }
1679  byte[] buffer = new byte[buffer_size];
1680  status = Status = Ailia.ailiaSummary(ailia, buffer, buffer_size);
1681  if (status != Ailia.AILIA_STATUS_SUCCESS)
1682  {
1683  if (logging)
1684  {
1685  Debug.Log("ailiaSummary failed " + status + " (" + GetStatusString(status) + ")");
1686  }
1687  return null;
1688  }
1689  return System.Text.Encoding.ASCII.GetString(buffer);
1690  }
bool logging
Definition: AiliaModel.cs:32
Definition: Ailia.cs:20
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
static int ailiaGetSummaryLength(IntPtr net, ref UInt32 buffer_size)
Output the required buffer size for network Summary.
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
IntPtr ailia
Definition: AiliaModel.cs:24
static int ailiaSummary(IntPtr net, byte[] buffer, UInt32 buffer_size)
Display the name and shape of each Blob.

◆ OpenEx()

virtual bool AiliaModel.OpenEx ( Ailia.ailiaFileCallback  callback,
IntPtr  arg1,
IntPtr  arg2 
)
inlinevirtual

Creates a network object from a file callback.

Parameters
callbackUser-defined file access callback function structure
arg1Argument pointer notified to AILIA_USER_API_FOPEN
arg2Argument pointer notified to AILIA_USER_API_FOPEN
Returns
If this function is successful, it returns true , or false otherwise.  Creates a network object from a file callback.

Reimplemented in AiliaDetectorModel, AiliaFeatureExtractorModel, AiliaClassifierModel, and AiliaPoseEstimatorModel.

583  {
584  Close();
585 
586  int status = Status = Ailia.ailiaCreate(ref ailia, env_id, Ailia.AILIA_MULTITHREAD_AUTO);
587  if (status != Ailia.AILIA_STATUS_SUCCESS)
588  {
589  DisplayLicenseError(status);
590  if (logging)
591  {
592  Debug.Log("ailiaCreate failed " + status + " (" + GetStatusString(status) + ")");
593  }
594  return false;
595  }
596 
597  if (memory_mode != Ailia.AILIA_MEMORY_OPTIMAIZE_DEFAULT)
598  {
599  status = Status = Ailia.ailiaSetMemoryMode(ailia, memory_mode);
600  if (status != Ailia.AILIA_STATUS_SUCCESS)
601  {
602  if (logging)
603  {
604  Debug.Log("ailiaSetMemoryMode failed " + status + " (" + GetStatusString(status) + ")");
605  }
606  Close();
607  return false;
608  }
609  }
610  if (disalbe_layer_fusion)
611  {
613  if (status != Ailia.AILIA_STATUS_SUCCESS)
614  {
615  if (logging)
616  {
617  Debug.Log("ailiaDisableLayerFusion failed " + status + " (" + GetStatusString(status) + ")");
618  }
619  Close();
620  return false;
621  }
622  }
623 
624  if (arg1 != null)
625  {
627  if (status != Ailia.AILIA_STATUS_SUCCESS)
628  {
629  if (logging)
630  {
631  Debug.Log("ailiaOpenStreamFileEx failed " + status + " (" + GetStatusString(status) + ")");
632  }
633  Close();
634  return false;
635  }
636  }
637 
639  if (status != Ailia.AILIA_STATUS_SUCCESS)
640  {
641  if (logging)
642  {
643  Debug.Log("ailiaOpenWeightFileEx failed " + status + " (" + GetStatusString(status) + ")");
644  }
645  Close();
646  return false;
647  }
648 
649  return true;
650  }
bool logging
Definition: AiliaModel.cs:32
Definition: Ailia.cs:20
const Int32 AILIA_MEMORY_OPTIMAIZE_DEFAULT
Definition: Ailia.cs:1464
const int AILIA_MULTITHREAD_AUTO
Definition: Ailia.cs:360
static int ailiaDisableLayerFusion(IntPtr net)
Disables layer integration during inference.
virtual void Close()
Destroys network objects.
Definition: AiliaModel.cs:1527
static int ailiaSetMemoryMode(IntPtr net, UInt32 mode)
Sets the memory usage policy during inference.
const Int32 AILIA_FILE_CALLBACK_VERSION
Definition: Ailia.cs:304
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
static int ailiaCreate(ref IntPtr net, int env_id, int num_thread)
Create a network object.
IntPtr ailia
Definition: AiliaModel.cs:24
static int ailiaOpenWeightEx(IntPtr net, IntPtr fopen_args, ailiaFileCallback callback, Int32 version)
Load weight coefficients into network object. (user-defined file access callback) ...
static int ailiaOpenStreamEx(IntPtr net, IntPtr fopen_args, ailiaFileCallback callback, Int32 version)
Initialize network object. (user-defined file access callback)

◆ OpenFile()

virtual bool AiliaModel.OpenFile ( string  prototxt_path,
string  model_path 
)
inlinevirtual

Create a network object from a model file.

Parameters
prototxt_path Pathname of the prototxt file(MBSC or UTF16)
model_pathPath name of protobuf/onnx file(MBSC or UTF16)
Returns
If this function is successful, it returns true , or false otherwise. Create a network object from a model file.

Reimplemented in AiliaDetectorModel, AiliaFeatureExtractorModel, AiliaClassifierModel, and AiliaPoseEstimatorModel.

385  {
386  Close();
387 
388  int status = Status = Ailia.ailiaCreate(ref ailia, env_id, Ailia.AILIA_MULTITHREAD_AUTO);
389  if (status != Ailia.AILIA_STATUS_SUCCESS)
390  {
391  DisplayLicenseError(status);
392  if (logging)
393  {
394  Debug.Log("ailiaCreate failed " + status + " (" + GetStatusString(status) + ")");
395  }
396  return false;
397  }
398 
399  if (memory_mode != Ailia.AILIA_MEMORY_OPTIMAIZE_DEFAULT)
400  {
401  status = Status = Ailia.ailiaSetMemoryMode(ailia, memory_mode);
402  if (status != Ailia.AILIA_STATUS_SUCCESS)
403  {
404  if (logging)
405  {
406  Debug.Log("ailiaSetMemoryMode failed " + status + " (" + GetStatusString(status) + ")");
407  }
408  Close();
409  return false;
410  }
411  }
412  if (disalbe_layer_fusion)
413  {
415  if (status != Ailia.AILIA_STATUS_SUCCESS)
416  {
417  if (logging)
418  {
419  Debug.Log("ailiaDisableLayerFusion failed " + status + " (" + GetStatusString(status) + ")");
420  }
421  Close();
422  return false;
423  }
424  }
425 
426  if (prototxt_path != null)
427  {
428  status = Status = Ailia.ailiaOpenStreamFile(ailia, prototxt_path);
429  if (status != Ailia.AILIA_STATUS_SUCCESS)
430  {
431  if (logging)
432  {
433  Debug.Log("ailiaOpenStreamFile failed " + status + " (" + GetStatusString(status) + ")");
434  }
435  Close();
436  return false;
437  }
438  }
439 
440  status = Status = Ailia.ailiaOpenWeightFile(ailia, model_path);
441  if (status != Ailia.AILIA_STATUS_SUCCESS)
442  {
443  if (logging)
444  {
445  Debug.Log("ailiaOpenWeightFile failed " + status + " (" + GetStatusString(status) + ")");
446  }
447  Close();
448  return false;
449  }
450 
451  return true;
452  }
bool logging
Definition: AiliaModel.cs:32
static int ailiaOpenWeightFile(IntPtr net, string path)
Load weight coefficients into network object.
Definition: Ailia.cs:20
const Int32 AILIA_MEMORY_OPTIMAIZE_DEFAULT
Definition: Ailia.cs:1464
const int AILIA_MULTITHREAD_AUTO
Definition: Ailia.cs:360
static int ailiaDisableLayerFusion(IntPtr net)
Disables layer integration during inference.
virtual void Close()
Destroys network objects.
Definition: AiliaModel.cs:1527
static int ailiaSetMemoryMode(IntPtr net, UInt32 mode)
Sets the memory usage policy during inference.
static int ailiaOpenStreamFile(IntPtr net, string path)
Initialize network object. (read from file)
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
static int ailiaCreate(ref IntPtr net, int env_id, int num_thread)
Create a network object.
IntPtr ailia
Definition: AiliaModel.cs:24

◆ OpenMem()

virtual bool AiliaModel.OpenMem ( byte []  prototxt_buf,
byte []  model_buf 
)
inlinevirtual

Creates network objects from memory.

Parameters
prototxt_bufPointer to data in  prototxt  file
model_bufPointer to data in protobuf/onnx file
Returns
If this function is successful, it returns true , or false otherwise. Creates network objects from memory.

Reimplemented in AiliaDetectorModel, AiliaFeatureExtractorModel, AiliaClassifierModel, and AiliaPoseEstimatorModel.

478  {
479  Close();
480 
481  if (model_buf == null || model_buf.Length == 0 || (prototxt_buf != null && prototxt_buf.Length == 0))
482  {
483  if (logging)
484  {
485  Debug.Log("input buffer is empty");
486  }
487  return false;
488  }
489 
490  int status = Status = Ailia.ailiaCreate(ref ailia, env_id, Ailia.AILIA_MULTITHREAD_AUTO);
491  if (status != Ailia.AILIA_STATUS_SUCCESS)
492  {
493  DisplayLicenseError(status);
494  if (logging)
495  {
496  Debug.Log("ailiaCreate failed " + status + " (" + GetStatusString(status) + ")");
497  }
498  return false;
499  }
500 
501  if (memory_mode != Ailia.AILIA_MEMORY_OPTIMAIZE_DEFAULT)
502  {
503  status = Status = Ailia.ailiaSetMemoryMode(ailia, memory_mode);
504  if (status != Ailia.AILIA_STATUS_SUCCESS)
505  {
506  if (logging)
507  {
508  Debug.Log("ailiaSetMemoryMode failed " + status + " (" + GetStatusString(status) + ")");
509  }
510  Close();
511  return false;
512  }
513  }
514  if (disalbe_layer_fusion)
515  {
517  if (status != Ailia.AILIA_STATUS_SUCCESS)
518  {
519  if (logging)
520  {
521  Debug.Log("ailiaDisableLayerFusion failed " + status + " (" + GetStatusString(status) + ")");
522  }
523  Close();
524  return false;
525  }
526  }
527 
528  if (prototxt_buf != null)
529  {
530  status = Status = Ailia.ailiaOpenStreamMem(ailia, prototxt_buf, (uint)prototxt_buf.Length);
531  if (status != Ailia.AILIA_STATUS_SUCCESS)
532  {
533  if (logging)
534  {
535  Debug.Log("ailiaOpenStreamMem failed " + status + " (" + GetStatusString(status) + ")");
536  }
537  Close();
538  return false;
539  }
540  }
541 
542  status = Status = Ailia.ailiaOpenWeightMem(ailia, model_buf, (uint)model_buf.Length);
543  if (status != Ailia.AILIA_STATUS_SUCCESS)
544  {
545  if (logging)
546  {
547  Debug.Log("ailiaOpenWeightMem filed " + status + " (" + GetStatusString(status) + ")");
548  }
549  Close();
550  return false;
551  }
552 
553  return true;
554  }
bool logging
Definition: AiliaModel.cs:32
static int ailiaOpenStreamMem(IntPtr net, byte[] buf, UInt32 buf_size)
Initialize network object. (read from memory)
Definition: Ailia.cs:20
const Int32 AILIA_MEMORY_OPTIMAIZE_DEFAULT
Definition: Ailia.cs:1464
const int AILIA_MULTITHREAD_AUTO
Definition: Ailia.cs:360
static int ailiaDisableLayerFusion(IntPtr net)
Disables layer integration during inference.
virtual void Close()
Destroys network objects.
Definition: AiliaModel.cs:1527
static int ailiaSetMemoryMode(IntPtr net, UInt32 mode)
Sets the memory usage policy during inference.
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
static int ailiaCreate(ref IntPtr net, int env_id, int num_thread)
Create a network object.
IntPtr ailia
Definition: AiliaModel.cs:24
static int ailiaOpenWeightMem(IntPtr net, byte[] buf, UInt32 buf_size)
Load weight coefficients into network object. (read from memory)

◆ Predict()

bool AiliaModel.Predict ( float []  output_data,
float []  input_data 
)
inline

Perform inference and obtain inference results.

Parameters
output_dataOutput data export destination
input_dataInference data
Returns
If this function is successful, it returns true , or false otherwise. Ailia.ailiaPredict() is used to infer with input_data as input and output to output_data. This API is available for 1-input, 1-output models. To infer a multi-input/output model, use the SetInputBlobData, Update, and GetBlobData APIs.
681  {
682  if (ailia == IntPtr.Zero)
683  {
684  return false;
685  }
686 
687  //バッファの固定
688  GCHandle input_buf_handle = GCHandle.Alloc(input_data, GCHandleType.Pinned);
689  IntPtr input_buf_ptr = input_buf_handle.AddrOfPinnedObject();
690 
691  GCHandle output_buf_handle = GCHandle.Alloc(output_data, GCHandleType.Pinned);
692  IntPtr output_buf_ptr = output_buf_handle.AddrOfPinnedObject();
693 
694  //推論
695  int status = Status = Ailia.ailiaPredict(ailia, output_buf_ptr, (uint)(output_data.Length * 4), input_buf_ptr, (uint)(input_data.Length * 4));
696 
697  //バッファの開放
698  input_buf_handle.Free();
699  output_buf_handle.Free();
700 
701  if (status != Ailia.AILIA_STATUS_SUCCESS)
702  {
703  if (logging)
704  {
705  Debug.Log("ailiaPredict failed " + status + " (" + GetStatusString(status) + ")");
706  }
707  return false;
708  }
709  return true;
710  }
bool logging
Definition: AiliaModel.cs:32
Definition: Ailia.cs:20
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
IntPtr ailia
Definition: AiliaModel.cs:24
static int ailiaPredict(IntPtr net, IntPtr dest, UInt32 dest_size, IntPtr src, UInt32 src_size)
Infer and get the result of inference.

◆ SelectEnvironment()

bool AiliaModel.SelectEnvironment ( int  idx)
inline

Select the calculation environment.

Parameters
idxIndex of Environmental Information (0~ ailiaGetEnvironmentCount() -1)
Returns
Returns true on success, false on failure.

Selects the computing environment for the specified index as the inference environment.

194  {
196  if (env == null)
197  {
198  return false;
199  }
200  env_id = env.id;
201  env_name = Marshal.PtrToStringAnsi(env.name);
202  return true;
203  }
Definition: Ailia.cs:20
Ailia.AILIAEnvironment GetEnvironment(int idx)
Obtains the computing environment for the specified index.
Definition: AiliaModel.cs:156
Definition: Ailia.cs:1254

◆ SetInputBlobData() [1/2]

bool AiliaModel.SetInputBlobData ( float []  input_data,
uint  idx 
)
inline

Set input data to the specified Blob.

Parameters
input_dataInference data X,Y,Z,W, in that order, stored as numeric type Size is inputSize of net file (I'm not sure if this is strictly the same as ailia.cs description, since buffer is allocated)
idxIndex of Blob to change settings
Returns
Returns true on success, false on failure.

Ailia.ailiaSetInPutBlobData() gives the input data to the specified Blob.

1187  {
1188  if (ailia == IntPtr.Zero)
1189  {
1190  return false;
1191  }
1192 
1193  GCHandle input_buf_handle = GCHandle.Alloc(input_data, GCHandleType.Pinned);
1194  IntPtr input_buf_ptr = input_buf_handle.AddrOfPinnedObject();
1195  int status = Status = Ailia.ailiaSetInputBlobData(ailia, input_buf_ptr, (uint)(input_data.Length * 4), idx);
1196  input_buf_handle.Free();
1197 
1198  if (status != Ailia.AILIA_STATUS_SUCCESS)
1199  {
1200  if (logging)
1201  {
1202  Debug.Log("ailiaSetInputBlobData failed " + status + " (" + GetStatusString(status) + ")");
1203  }
1204  return false;
1205  }
1206  return true;
1207  }
bool logging
Definition: AiliaModel.cs:32
Definition: Ailia.cs:20
static int ailiaSetInputBlobData(IntPtr net, IntPtr src, UInt32 src_size, UInt32 blob_idx)
Give input data to the specified Blob.
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
IntPtr ailia
Definition: AiliaModel.cs:24

◆ SetInputBlobData() [2/2]

public bool AiliaModel.SetInputBlobData ( float []  input_data,
int  idx 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

1217  {
1218  if (ailia == IntPtr.Zero || idx < 0)
1219  {
1220  return false;
1221  }
1222  return SetInputBlobData(input_data, (uint)idx);
1223  }
bool SetInputBlobData(float[] input_data, uint idx)
Set input data to the specified Blob.
Definition: AiliaModel.cs:1186
IntPtr ailia
Definition: AiliaModel.cs:24

◆ SetInputBlobShape() [1/2]

bool AiliaModel.SetInputBlobShape ( Ailia.AILIAShape  shape,
uint  idx 
)
inline

Sets the format of the specified input data (Blob). (4 dimensions or less)

Parameters
shapeShape information of input data
idxIndex of Blob to be changed
Returns
Returns true on success, false on failure. Used to change the input shape of a network with multiple inputs, for example. Changes the format of the input data (Blob) specified in Ailia.ailiaSetInputBlobShape(). If the input shape has a rank of 5 or more dimensions, use SetInputShapeND().
1253  {
1254  if (ailia == IntPtr.Zero)
1255  {
1256  return false;
1257  }
1258 
1259  int status = Status = Ailia.ailiaSetInputBlobShape(ailia, shape, idx, Ailia.AILIA_SHAPE_VERSION);
1260  if (status != Ailia.AILIA_STATUS_SUCCESS)
1261  {
1262  if (logging)
1263  {
1264  Debug.Log("ailiaSetInputBlobShape failed " + status + " (" + GetStatusString(status) + ")");
1265  }
1266  return false;
1267  }
1268  return true;
1269  }
bool logging
Definition: AiliaModel.cs:32
const Int32 AILIA_SHAPE_VERSION
Definition: Ailia.cs:310
Definition: Ailia.cs:20
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
static int ailiaSetInputBlobShape(IntPtr net, [In] AILIAShape shape, UInt32 blob_idx, UInt32 version)
Change the shape of the specified Blob.
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
IntPtr ailia
Definition: AiliaModel.cs:24

◆ SetInputBlobShape() [2/2]

public bool AiliaModel.SetInputBlobShape ( Ailia.AILIAShape  shape,
int  idx 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

1279  {
1280  if (idx < 0)
1281  {
1282  return false;
1283  }
1284  return SetInputBlobShape(shape, (uint)idx);
1285  }
bool SetInputBlobShape(Ailia.AILIAShape shape, uint idx)
Sets the format of the specified input data (Blob). (4 dimensions or less)
Definition: AiliaModel.cs:1252

◆ SetInputBlobShapeND() [1/2]

bool AiliaModel.SetInputBlobShapeND ( uint []  shape,
uint  dim,
uint  idx 
)
inline

Sets the format of the input data (Blob). (5D or more)

Parameters
shapeShape information of input data
dimDimensions of shape
idxIndex of Blob to be changed
Returns
Returns true on success, false on failure. Used to change the input shape of a network with multiple inputs, for example. Changes the format of the input data (Blob) specified in Ailia.ailiaSetInputBlobShapeND().
1311  {
1312  if (ailia == IntPtr.Zero)
1313  {
1314  return false;
1315  }
1316 
1317  int status = Status = Ailia.ailiaSetInputBlobShapeND(ailia, shape, dim, idx);
1318  if (status != Ailia.AILIA_STATUS_SUCCESS)
1319  {
1320  if (logging)
1321  {
1322  Debug.Log("ailiaSetInputBlobShapeND failed " + status + " (" + GetStatusString(status) + ")");
1323  }
1324  return false;
1325  }
1326  return true;
1327  }
bool logging
Definition: AiliaModel.cs:32
Definition: Ailia.cs:20
static int ailiaSetInputBlobShapeND(IntPtr net, UInt32[] shape, UInt32 dim, UInt32 blob_idx)
Change the shape of the specified Blob.
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
IntPtr ailia
Definition: AiliaModel.cs:24

◆ SetInputBlobShapeND() [2/2]

public bool AiliaModel.SetInputBlobShapeND ( uint []  shape,
int  dim,
int  idx 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

1337  {
1338  if (idx < 0 || dim < 0)
1339  {
1340  return false;
1341  }
1342  return SetInputBlobShapeND(shape, (uint)dim, (uint)idx);
1343  }
bool SetInputBlobShapeND(uint[] shape, uint dim, uint idx)
Sets the format of the input data (Blob). (5D or more)
Definition: AiliaModel.cs:1310

◆ SetInputShape()

bool AiliaModel.SetInputShape ( Ailia.AILIAShape  shape)
inline

Sets the shape of the input data during inference.

Parameters
shapeShape information of input data
Returns
If this function is successful, it returns true , or false otherwise. Changes the input geometry defined in prototxt. It should be the same as the rank described in prototxt. Note that an error may be returned if the shape of the weight coefficients depends on the input geometry, for example. If the rank defined in prototxt is 5 or more dimensions, use SetInputShapeND().
830  {
831  if (ailia == IntPtr.Zero)
832  {
833  return false;
834  }
835 
837  if (status != Ailia.AILIA_STATUS_SUCCESS)
838  {
839  if (logging)
840  {
841  Debug.Log("ailiaSetInputShape failed " + status + " (" + GetStatusString(status) + ")");
842  }
843  return false;
844  }
845  return true;
846  }
bool logging
Definition: AiliaModel.cs:32
const Int32 AILIA_SHAPE_VERSION
Definition: Ailia.cs:310
Definition: Ailia.cs:20
static int ailiaSetInputShape(IntPtr net, [In] AILIAShape shape, UInt32 version)
Change the shape of input data during inference.
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
IntPtr ailia
Definition: AiliaModel.cs:24

◆ SetInputShapeND()

bool AiliaModel.SetInputShapeND ( uint []  shape,
int  dim 
)
inline

Change the shape of the input data during inference.

Parameters
netNetwork object pointer
shapeArray of sizes of each dimension of input data (dim-1, dim-2, ... ,1, 0)
dimDimensions of shape
Returns
If this function is successful, it returns true , or false otherwise.

Changes the input geometry defined in prototxt. It should be the same as the rank described in prototxt. Note that an error may be returned if the shape of the weight coefficients depends on the input geometry, for example.

874  {
875  if (ailia == IntPtr.Zero || dim < 0)
876  {
877  return false;
878  }
879 
880  int status = Status = Ailia.ailiaSetInputShapeND(ailia, shape, (uint)dim);
881  if (status != Ailia.AILIA_STATUS_SUCCESS)
882  {
883  if (logging)
884  {
885  Debug.Log("ailiaSetInputShapeND failed " + status + " (" + GetStatusString(status) + ")");
886  }
887  return false;
888  }
889  return true;
890  }
bool logging
Definition: AiliaModel.cs:32
Definition: Ailia.cs:20
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
IntPtr ailia
Definition: AiliaModel.cs:24
static int ailiaSetInputShapeND(IntPtr net, UInt32 [] shape, UInt32 dim)
Change the shape of input data during inference.

◆ SetMemoryMode()

void AiliaModel.SetMemoryMode ( uint  set_memory_mode)
inline

Sets the memory mode.

Parameters
set_memory_modeMemory mode (multiple specifiable by logical. AILIA_MEMORY_XXX (default: AILIA_MEMORY_REDUCE_CONSTANT )
Returns
no return value

Changes the memory usage policy setting; if anything other than AILIA_MEMORY_NO_OPTIMIZATION is specified, the intermediate buffer allocated during inference is released, thus reducing the amount of memory used during inference.

341  {
342  memory_mode = set_memory_mode;
343  }

◆ SetProfileMode()

bool AiliaModel.SetProfileMode ( uint  profile_mode)
inline

Enable profile mode.

Returns
Returns true on success, false on failure. Enable profile mode. After enabling profile mode and inference, get profile results in Summary API.
1637  {
1638  int status = Status = Ailia.ailiaSetProfileMode(ailia, profile_mode);
1639  if (status != Ailia.AILIA_STATUS_SUCCESS)
1640  {
1641  if (logging)
1642  {
1643  Debug.Log("ailiaSetProfileMode failed " + status + " (" + GetStatusString(status) + ")");
1644  }
1645  return false;
1646  }
1647  return true;
1648  }
static int ailiaSetProfileMode(IntPtr net, UInt32 mode)
Set profile mode.
bool logging
Definition: AiliaModel.cs:32
Definition: Ailia.cs:20
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
IntPtr ailia
Definition: AiliaModel.cs:24

◆ Update()

bool AiliaModel.Update ( )
inline

Inference is performed with pre-populated data.

Returns
Returns true on success, false on failure. This is used, for example, when SetInputBlobData() is used to provide input. Inference results should be obtained with GetBlobData().
1496  {
1497  if (ailia == IntPtr.Zero)
1498  {
1499  return false;
1500  }
1501  int status = Status = Ailia.ailiaUpdate(ailia);
1502  if (status != Ailia.AILIA_STATUS_SUCCESS)
1503  {
1504  if (logging)
1505  {
1506  Debug.Log("ailiaUpdate failed " + status + " (" + GetStatusString(status) + ")");
1507  }
1508  return false;
1509  }
1510  return true;
1511  }
static int ailiaUpdate(IntPtr net)
Perform inference with pre-specified input data.
bool logging
Definition: AiliaModel.cs:32
Definition: Ailia.cs:20
string GetStatusString(int status)
Returns a string corresponding to the status code.
Definition: AiliaModel.cs:1580
int Status
Status code Get the library status code.
Definition: AiliaModel.cs:1618
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
IntPtr ailia
Definition: AiliaModel.cs:24

Member Data Documentation

◆ ailia

IntPtr AiliaModel.ailia = IntPtr.Zero
protected

◆ logging

bool AiliaModel.logging = true
protected

Property Documentation

◆ Status

int AiliaModel.Status
getprotected set

Status code Get the library status code.

1618 { get; protected set; }

The documentation for this class was generated from the following file: