Values:
Handle for DLRModel.
A pointer to a malloc-like function.
A pointer to a free-like function.
A pointer to a memalign-like function.
Creates a DLR model.
Creates a DLR model.
handle – The pointer to save the model handle.
model_path – Path to the folder containing the model files, or colon-separated list of folders containing model files, or colon-separated list of paths to model files
dev_type – Device type. Valid values are in the DLDeviceType enum in dlpack.h.
dev_id – Device ID.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Creates a DLR model from model elements.
handle – The pointer to save the model handle.
model_elems – DLR Model elements. Element can be file path or data pointer in memory.
dev_type – Device type. Valid values are in the DLDeviceType enum in dlpack.h.
dev_id – Device ID.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Creates a DLR pipeline model.
Creates a DLR pipeline model.
handle – The pointer to save the model handle.
num_models – Number of items in model_paths array
model_paths – Paths to the folders containing the models files, or colon-separated list of folders (or files) if model files stored in different locations
dev_type – Device type. Valid values are in the DLDeviceType enum in dlpack.h.
dev_id – Device ID.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Deletes a DLR model.
handle – The model handle returned from CreateDLRModel().
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Runs a DLR model.
handle – The model handle returned from CreateDLRModel().
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Gets the number of inputs.
handle – The model handle returned from CreateDLRModel().
num_inputs – The pointer to save the number of inputs.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Gets the number of weights.
handle – The model handle returned from CreateDLRModel().
num_weights – The pointer to save the number of weights.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Gets the name of the index-th input.
handle – The model handle returned from CreateDLRModel().
index – The index of the input.
input_name – The pointer to save the name of the index-th input.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Gets the type of the index-th input.
handle – The model handle returned from CreateDLRModel().
index – The index of the input.
input_type – The pointer to save the type of the index-th input.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Gets the name of the index-th weight.
handle – The model handle returned from CreateDLRModel().
index – The index of the weight.
input_name – The pointer to save the name of the index-th weight.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Sets the input according the node name.
handle – The model handle returned from CreateDLRModel().
name – The input node name.
shape – The input node shape as an array.
input – The data for the input as an array.
dim – The dimension of the input data.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Sets the input according the node name from existing DLTensor. Can only be used with TVM models (GraphExecutor and VMRuntime)
handle – The model handle returned from CreateDLRModel().
name – The input node name.
tensor – The input DLTensor.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Sets the input from existing DLTensor without copying data. Can only be used with TVM models (GraphExecutor). Input tensor device must match the device of the model, and data must be alligned to 128 bytes. GetDLRInput cannot be used for inputs set via SetDLRInputZeroCopy.
handle – The model handle returned from CreateDLRModel().
name – The input node name.
tensor – The input DLTensor.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Gets the current value of the input according the node name.
handle – The model handle returned from CreateDLRModel().
name – The input node name.
input – The current value of the input will be copied to this buffer.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Gets the shape of the index-th input.
handle – The model handle returned from CreateDLRModel().
index – The index-th input.
shape – The pointer to save the shape of index-th input. This should be a pointer to an array of size “dim” from GetDLRInputSizeDim().
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Gets the size and dimension of an input.
handle – The model handle returned from CreateDLRModel().
index – The index-th input.
size – The pointer to save the size of the index-th input.
dim – The pointer to save the dimension of the index-th output.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Gets the shape of the index-th output.
handle – The model handle returned from CreateDLRModel().
index – The index-th output.
shape – The pointer to save the shape of index-th output. This should be a pointer to an array of size “dim” from GetDLROutputSizeDim().
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Gets the index-th output from the model.
handle – The model handle returned from CreateDLRModel().
index – The index-th output.
out – The pointer to save the output data. This should be a pointer to an array of size “size” from GetDLROutputSizeDim().
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Gets the index-th output from the model.
handle – The model handle returned from CreateDLRModel().
index – The index-th output.
out – Storage to save output pointer
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Gets the index-th output from the model and copies it into the given DLTensor. Can only be used with TVM models (GraphExecutor and VMRuntime)
handle – The model handle returned from CreateDLRModel().
index – The index-th output.
tensor – The pointer to an existing/allocated DLTensor to copy the output into.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Gets the index-th output from the model and sets the pointer to it. Can only be used with TVM models (GraphExecutor and VMRuntime)
handle – The model handle returned from CreateDLRModel().
index – The index-th output.
tensor – The pointer to an unallocated DLManagedTensor pointer, will be set by this function to point to an internal DLManagedTensor.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Gets the number of outputs.
handle – The model handle returned from CreateDLRModel().
num_outputs – The pointer to save the number of outputs.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Gets the size and dimension of an output.
handle – The model handle returned from CreateDLRModel().
index – The index-th output.
size – The pointer to save the size of the index-th output.
dim – The pointer to save the dimension of the index-th output.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Gets the type of the index-th output.
handle – The model handle returned from CreateDLRModel().
index – The index of the output.
output_type – The pointer to save the type of the index-th output.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Check if metadata file is found in the compilation artifact.
handle – The model handle returned from CreateDLRModel().
has_metadata – The pointer to save boolean value to indicate the presence of metadata file.
Gets the output node names of the uncompiled model from the metadata file.
handle – The model handle returned from CreateDLRModel().
names – The pointer to save array containing output node names.
Gets the output node index using the node name.
handle – The model handle returned from CreateDLRModel().
name – The pointer pointing to the output node name.
index – The pointer to save the corresponding index of the output node.
Gets the output of the node of the given name from the model.
handle – The model handle returned from CreateDLRModel().
name – The name of the output node.
out – The pointer to save the output data. This should be a pointer to an array of size “size” from GetDLROutputSizeDim().
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Gets the last error message.
Null-terminated string containing the error message.
Gets the name of the backend (“tvm”, “treelite” or “tflite”)
handle – The model handle returned from CreateDLRModel().
name – The pointer to save the null-terminated string containing the name.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Gets the DLDeviceType (DLDeviceType::kDLCPU, DLDeviceType::kDLGPU, etc)
model_path – Path to the folder containing the model files, or colon-separated list of folders (or files) if model files
DLDeviceType enum for success, -1 for error. Call DLRGetLastError() to get the error message.
Get DLR version.
out – The pointer to save the null-terminated string containing the version.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Set the number of threads available to DLR.
handle – The model handle returned from CreateDLRModel().
threads – number of threads
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Enable or disable CPU Affinity.
handle – The model handle returned from CreateDLRModel().
use – 0 to disable, 1 to enable
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Set custom allocator malloc function. Must be called before CreateDLRModel or CreateDLRPipeline. It is recommended to use with SetDLRCustomAllocatorFree and SetDLRCustomAllocatorMemalign.
custom_memalign_fn – Function pointer to memalign-like function.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Set custom allocator free function. Must be called before CreateDLRModel or CreateDLRPipeline. It is recommended to use with SetDLRCustomAllocatorMalloc and SetDLRCustomAllocatorMemalign.
custom_free_fn – Function pointer to free-like function.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.
Set custom allocator memalign function. memalign is used heavily by the TVM and RelayVM backends. Must be called before CreateDLRModel or CreateDLRPipeline. It is recommended to use with SetDLRCustomAllocatorMalloc and SetDLRCustomAllocatorFree.
custom_memalign_fn – Function pointer to memalign-like function.
0 for success, -1 for error. Call DLRGetLastError() to get the error message.