.. _program_listing_file_src_servables_custom_custom.h: Program Listing for File custom.h ================================= |exhale_lsh| :ref:`Return to documentation for file ` (``src/servables/custom/custom.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * 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. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``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 OWNER 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. #pragma once #include #include #ifdef __cplusplus extern "C" { #endif #define CUSTOM_NO_GPU_DEVICE -1 #define CUSTOM_SERVER_PARAMETER_CNT 2 typedef enum custom_serverparamkind_enum { INFERENCE_SERVER_VERSION = 0, MODEL_REPOSITORY_PATH = 1 } CustomServerParameter; // The initialization information provided to a custom backend when it // is created. typedef struct custom_initdata_struct { const char* instance_name; const char* serialized_model_config; size_t serialized_model_config_size; int gpu_device_id; size_t server_parameter_cnt; const char** server_parameters; } CustomInitializeData; typedef struct custom_payload_struct { uint32_t batch_size; uint32_t input_cnt; const char** input_names; const size_t* input_shape_dim_cnts; const int64_t** input_shape_dims; uint32_t output_cnt; const char** required_output_names; void* input_context; void* output_context; int error_code; } CustomPayload; typedef bool (*CustomGetNextInputFn_t)( void* input_context, const char* name, const void** content, uint64_t* content_byte_size); typedef bool (*CustomGetOutputFn_t)( void* output_context, const char* name, size_t shape_dim_cnt, int64_t* shape_dims, uint64_t content_byte_size, void** content); typedef int (*CustomInitializeFn_t)(const CustomInitializeData*, void**); typedef int (*CustomFinalizeFn_t)(void*); typedef char* (*CustomErrorStringFn_t)(void*, int); typedef int (*CustomExecuteFn_t)( void*, uint32_t, CustomPayload*, CustomGetNextInputFn_t, CustomGetOutputFn_t); int CustomInitialize(const CustomInitializeData* data, void** custom_context); int CustomFinalize(void* custom_context); const char* CustomErrorString(void* custom_context, int errcode); int CustomExecute( void* custom_context, uint32_t payload_cnt, CustomPayload* payloads, CustomGetNextInputFn_t input_fn, CustomGetOutputFn_t output_fn); #ifdef __cplusplus } #endif