|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- ! BSD 2-Clause License
- !
- ! Copyright (c) 2021-2022, Hewlett Packard Enterprise
- ! All rights reserved.
- !
- ! Redistribution and use in source and binary forms, with or without
- ! modification, are permitted provided that the following conditions are met:
- !
- ! 1. Redistributions of source code must retain the above copyright notice, this
- ! list of conditions and the following disclaimer.
- !
- ! 2. Redistributions in binary form must reproduce the above copyright notice,
- ! this list of conditions and the following disclaimer in the documentation
- ! and/or other materials provided with the distribution.
- !
- ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- ! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- ! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- ! DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- ! FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- ! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- ! SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- ! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- ! OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- ! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- interface
- function get_model_c( c_client, key, key_length, model, model_length, model_data) bind(c,name="get_model")
- use iso_c_binding, only : c_ptr, c_char, c_size_t
- import :: enum_kind
- integer(kind=enum_kind) :: get_model_c
- type(c_ptr), value, intent(in) :: c_client !< Initialized SmartRedis client
- character(kind=c_char), intent(in) :: key(*) !< The key to use to place the model
- integer(kind=c_size_t), value, intent(in) :: key_length !< The length of the key c-string, excluding null
- type(c_ptr), intent(inout) :: model !< The model as a continuous buffer
- integer(kind=c_size_t), intent( out) :: model_length !< Length of the model buffer c-string
- type(c_ptr), intent( out) :: model_data !< Reeives model information
- end function get_model_c
- end interface
-
- interface
- function set_model_from_file_c( c_client, key, key_length, model_file, model_file_length, &
- backend, backend_length, device, device_length, batch_size, min_batch_size, tag, tag_length, &
- inputs, input_lengths, n_inputs, outputs, output_lengths, n_outputs ) bind(c, name="set_model_from_file")
- use iso_c_binding, only : c_ptr, c_size_t, c_int, c_char
- import :: enum_kind
- integer(kind=enum_kind) :: set_model_from_file_c
- type(c_ptr), value, intent(in) :: c_client !< Initialized SmartRedis client
- character(kind=c_char), intent(in) :: key(*) !< The key to use to place the model
- integer(kind=c_size_t), value, intent(in) :: key_length !< The length of the key c-string, excluding null
- character(kind=c_char), intent(in) :: model_file(*) !< The file storing the model
- integer(kind=c_size_t), value, intent(in) :: model_file_length !< The length of the file name c-string, excluding
- !! null terminating character
- character(kind=c_char), intent(in) :: backend(*) !< The name of the backend (TF, TFLITE, TORCH, ONNX)
- integer(kind=c_size_t), value, intent(in) :: backend_length !< The length of the backend name c-string,
- !! excluding null terminating character
- character(kind=c_char), intent(in) :: device(*) !< The name of the device (CPU, GPU, GPU:0, GPU:1...)
- integer(kind=c_size_t), value, intent(in) :: device_length !< The length of the device name c-string, excluding
- !! null terminating character
- integer(kind=c_int), value, intent(in) :: batch_size !< The batch size for model execution
- integer(kind=c_int), value, intent(in) :: min_batch_size !< The minimum batch size for model execution
- character(kind=c_char), intent(in) :: tag(*) !< A tag to attach to the model for information
- !! purposes
- integer(kind=c_size_t), value, intent(in) :: tag_length !< The length of the tag c-string, excluding null
- !! terminating character
- type(c_ptr), value, intent(in) :: inputs !< One or more names of model input nodes (TF models)
- type(c_ptr), value, intent(in) :: input_lengths !< The length of each input name c-string, excluding
- !! null terminating character
- integer(kind=c_size_t), value, intent(in) :: n_inputs !< The number of inputs
- type(c_ptr), value, intent(in) :: outputs !< One or more names of model output nodes
- !! (TF models)
- type(c_ptr), value, intent(in) :: output_lengths !< The length of each output name c-string,
- !! excluding null terminating character
- integer(kind=c_size_t), value, intent(in) :: n_outputs !< The number of outputs
- end function set_model_from_file_c
- end interface
-
- interface
- function set_model_from_file_multigpu_c( c_client, key, key_length, model_file, model_file_length, &
- backend, backend_length, first_gpu, num_gpus, batch_size, min_batch_size, tag, tag_length, &
- inputs, input_lengths, n_inputs, outputs, output_lengths, n_outputs ) bind(c, name="set_model_from_file_multigpu")
- use iso_c_binding, only : c_ptr, c_size_t, c_int, c_char
- import :: enum_kind
- integer(kind=enum_kind) :: set_model_from_file_multigpu_c
- type(c_ptr), value, intent(in) :: c_client !< Initialized SmartRedis client
- character(kind=c_char), intent(in) :: key(*) !< The key to use to place the model
- integer(kind=c_size_t), value, intent(in) :: key_length !< The length of the key c-string, excluding null
- character(kind=c_char), intent(in) :: model_file(*) !< The file storing the model
- integer(kind=c_size_t), value, intent(in) :: model_file_length !< The length of the file name c-string, excluding
- !! null terminating character
- character(kind=c_char), intent(in) :: backend(*) !< The name of the backend (TF, TFLITE, TORCH, ONNX)
- integer(kind=c_size_t), value, intent(in) :: backend_length !< The length of the backend name c-string,
- !! excluding null terminating character
- integer(kind=c_int), value, intent(in) :: first_gpu !< ID of the first GPU to set the model on
- integer(kind=c_int), value, intent(in) :: num_gpus !< How many GPUs to use in the orchestrator
- !! null terminating character
- integer(kind=c_int), value, intent(in) :: batch_size !< The batch size for model execution
- integer(kind=c_int), value, intent(in) :: min_batch_size !< The minimum batch size for model execution
- character(kind=c_char), intent(in) :: tag(*) !< A tag to attach to the model for information
- !! purposes
- integer(kind=c_size_t), value, intent(in) :: tag_length !< The length of the tag c-string, excluding null
- !! terminating character
- type(c_ptr), value, intent(in) :: inputs !< One or more names of model input nodes (TF models)
- type(c_ptr), value, intent(in) :: input_lengths !< The length of each input name c-string, excluding
- !! null terminating character
- integer(kind=c_size_t), value, intent(in) :: n_inputs !< The number of inputs
- type(c_ptr), value, intent(in) :: outputs !< One or more names of model output nodes
- !! (TF models)
- type(c_ptr), value, intent(in) :: output_lengths !< The length of each output name c-string,
- !! excluding null terminating character
- integer(kind=c_size_t), value, intent(in) :: n_outputs !< The number of outputs
- end function set_model_from_file_multigpu_c
- end interface
-
- interface
- function set_model_c( c_client, key, key_length, model, model_length, &
- backend, backend_length, device, device_length, batch_size, min_batch_size, tag, tag_length, &
- inputs, input_lengths, n_inputs, outputs, output_lengths, n_outputs ) bind(c, name="set_model")
- use iso_c_binding, only : c_ptr, c_size_t, c_int, c_char
- import :: enum_kind
- integer(kind=enum_kind) :: set_model_c
- type(c_ptr), value, intent(in) :: c_client !< Initialized SmartRedis client
- character(kind=c_char), intent(in) :: key(*) !< The key to use to place the model
- integer(kind=c_size_t), value, intent(in) :: key_length !< The length of the key c-string, excluding null
- character(kind=c_char), intent(in) :: model(*) !< The file storing the model
- integer(kind=c_size_t), value, intent(in) :: model_length !< The length of the file name c-string, excluding
- !! null terminating character
- character(kind=c_char), intent(in) :: backend(*) !< The name of the backend (TF, TFLITE, TORCH, ONNX)
- integer(kind=c_size_t), value, intent(in) :: backend_length !< The length of the backend name c-string,
- !! excluding null terminating character
- character(kind=c_char), intent(in) :: device(*) !< The name of the device (CPU, GPU, GPU:0, GPU:1...)
- integer(kind=c_size_t), value, intent(in) :: device_length !< The length of the device name c-string, excluding
- !! null terminating character
- integer(kind=c_int), value, intent(in) :: batch_size !< The batch size for model execution
- integer(kind=c_int), value, intent(in) :: min_batch_size !< The minimum batch size for model execution
- character(kind=c_char), intent(in) :: tag(*) !< A tag to attach to the model for information
- !! purposes
- integer(kind=c_size_t), value, intent(in) :: tag_length !< The length of the tag c-string, excluding null
- !! terminating character
- type(c_ptr), value, intent(in) :: inputs !< One or more names of model input nodes (TF models)
- type(c_ptr), value, intent(in) :: input_lengths !< The length of each input name c-string, excluding
- !! null terminating character
- integer(kind=c_size_t), value, intent(in) :: n_inputs !< The number of inputs
- type(c_ptr), value, intent(in) :: outputs !< One or more names of model output nodes
- !! (TF models)
- type(c_ptr), value, intent(in) :: output_lengths !< The length of each output name c-string,
- !! excluding null terminating character
- integer(kind=c_size_t), value, intent(in) :: n_outputs !< The number of outputs
- end function set_model_c
- end interface
-
- interface
- function set_model_multigpu_c( c_client, key, key_length, model, model_length, &
- backend, backend_length, first_gpu, num_gpus, batch_size, min_batch_size, tag, tag_length, &
- inputs, input_lengths, n_inputs, outputs, output_lengths, n_outputs ) bind(c, name="set_model_multigpu")
- use iso_c_binding, only : c_ptr, c_size_t, c_int, c_char
- import :: enum_kind
- integer(kind=enum_kind) :: set_model_multigpu_c
- type(c_ptr), value, intent(in) :: c_client !< Initialized SmartRedis client
- character(kind=c_char), intent(in) :: key(*) !< The key to use to place the model
- integer(kind=c_size_t), value, intent(in) :: key_length !< The length of the key c-string, excluding null
- character(kind=c_char), intent(in) :: model(*) !< The file storing the model
- integer(kind=c_size_t), value, intent(in) :: model_length !< The length of the file name c-string, excluding
- !! null terminating character
- character(kind=c_char), intent(in) :: backend(*) !< The name of the backend (TF, TFLITE, TORCH, ONNX)
- integer(kind=c_size_t), value, intent(in) :: backend_length !< The length of the backend name c-string,
- !! excluding null terminating character
- integer(kind=c_int), value, intent(in) :: first_gpu !< ID of the first GPU to set the model on
- integer(kind=c_int), value, intent(in) :: num_gpus !< How many GPUs to use in the orchestrator
- !! null terminating character
- integer(kind=c_int), value, intent(in) :: batch_size !< The batch size for model execution
- integer(kind=c_int), value, intent(in) :: min_batch_size !< The minimum batch size for model execution
- character(kind=c_char), intent(in) :: tag(*) !< A tag to attach to the model for information
- !! purposes
- integer(kind=c_size_t), value, intent(in) :: tag_length !< The length of the tag c-string, excluding null
- !! terminating character
- type(c_ptr), value, intent(in) :: inputs !< One or more names of model input nodes (TF models)
- type(c_ptr), value, intent(in) :: input_lengths !< The length of each input name c-string, excluding
- !! null terminating character
- integer(kind=c_size_t), value, intent(in) :: n_inputs !< The number of inputs
- type(c_ptr), value, intent(in) :: outputs !< One or more names of model output nodes
- !! (TF models)
- type(c_ptr), value, intent(in) :: output_lengths !< The length of each output name c-string,
- !! excluding null terminating character
- integer(kind=c_size_t), value, intent(in) :: n_outputs !< The number of outputs
- end function set_model_multigpu_c
- end interface
-
- interface
- function run_model_c(c_client, key, key_length, inputs, input_lengths, n_inputs, &
- outputs, output_lengths, n_outputs) bind(c, name="run_model")
- use iso_c_binding, only : c_ptr, c_size_t, c_char
- import :: enum_kind
- integer(kind=enum_kind) :: run_model_c
- type(c_ptr), value, intent(in) :: c_client !< Initialized SmartRedis client
- character(kind=c_char), intent(in) :: key(*) !< The key to use to place the model
- integer(kind=c_size_t), value, intent(in) :: key_length !< The length of the key c-string, excluding null
- type(c_ptr), value, intent(in) :: inputs !< One or more names of model input nodes (TF models)
- type(c_ptr), value, intent(in) :: input_lengths !< The length of each input name c-string, excluding
- !! null terminating character
- integer(kind=c_size_t), value, intent(in) :: n_inputs !< The number of inputs
- type(c_ptr), value, intent(in) :: outputs !< One or more names of model output nodes
- !! (TF models)
- type(c_ptr), value, intent(in) :: output_lengths !< The length of each output name c-string,
- !! excluding null terminating character
- integer(kind=c_size_t), value, intent(in) :: n_outputs !< The number of outputs
- end function run_model_c
- end interface
-
- interface
- function run_model_multigpu_c(c_client, key, key_length, inputs, input_lengths, n_inputs, &
- outputs, output_lengths, n_outputs, offset, first_gpu, num_gpus) &
- bind(c, name="run_model_multigpu")
- use iso_c_binding, only : c_ptr, c_size_t, c_char, c_int
- import :: enum_kind
- integer(kind=enum_kind) :: run_model_multigpu_c
- type(c_ptr), value, intent(in) :: c_client !< Initialized SmartRedis client
- character(kind=c_char), intent(in) :: key(*) !< The key to use to place the model
- integer(kind=c_size_t), value, intent(in) :: key_length !< The length of the key c-string, excluding null
- type(c_ptr), value, intent(in) :: inputs !< One or more names of model input nodes (TF models)
- type(c_ptr), value, intent(in) :: input_lengths !< The length of each input name c-string, excluding
- !! null terminating character
- integer(kind=c_size_t), value, intent(in) :: n_inputs !< The number of inputs
- type(c_ptr), value, intent(in) :: outputs !< One or more names of model output nodes
- !! (TF models)
- type(c_ptr), value, intent(in) :: output_lengths !< The length of each output name c-string,
- !! excluding null terminating character
- integer(kind=c_size_t), value, intent(in) :: n_outputs !< The number of outputs
- integer(kind=c_int), value, intent(in) :: offset !< Index of the current image, such as a processor
- !! ID or MPI rank
- integer(kind=c_int), value, intent(in) :: first_gpu !< ID of the first GPU to use the model on
- integer(kind=c_int), value, intent(in) :: num_gpus !< How many GPUs to use in the orchestrator
- end function run_model_multigpu_c
- end interface
-
- interface
- function delete_model_c(c_client, key, key_length) bind(c, name="delete_model")
- use iso_c_binding, only : c_ptr, c_size_t, c_char
- import :: enum_kind
- integer(kind=enum_kind) :: delete_model_c
- type(c_ptr), value, intent(in) :: c_client !< Initialized SmartRedis client
- character(kind=c_char), intent(in) :: key(*) !< The key to use to delete the model
- integer(kind=c_size_t), value, intent(in) :: key_length !< The length of the key c-string, excluding null
- end function delete_model_c
- end interface
-
- interface
- function delete_model_multigpu_c(c_client, key, key_length, first_gpu, num_gpus) bind(c, name="delete_model_multigpu")
- use iso_c_binding, only : c_ptr, c_size_t, c_char, c_int
- import :: enum_kind
- integer(kind=enum_kind) :: delete_model_multigpu_c
- type(c_ptr), value, intent(in) :: c_client !< Initialized SmartRedis client
- character(kind=c_char), intent(in) :: key(*) !< The key to use to delete the model
- integer(kind=c_size_t), value, intent(in) :: key_length !< The length of the key c-string, excluding null
- integer(kind=c_int), value, intent(in) :: first_gpu !< ID of the first GPU to use the model on
- integer(kind=c_int), value, intent(in) :: num_gpus !< How many GPUs to use in the orchestrator
- end function delete_model_multigpu_c
- end interface
|