Skip to content

Commit

Permalink
Fix alloc_fn in grpc/http frontend to match trtserver.h description... (
Browse files Browse the repository at this point in the history
triton-inference-server#566)

Check memory type and expect repeated call only if byte size is non-zero
  • Loading branch information
GuanLuo authored and deadeyegoodwin committed Aug 20, 2019
1 parent 4d5a55c commit a2a24d6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/servers/grpc_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ AsyncResources::ResponseAlloc(
*buffer = nullptr;
*buffer_userp = nullptr;

// Can't allocate for any memory type other than CPU.
if (memory_type != TRTSERVER_MEMORY_CPU) {
// Can't allocate for any memory type other than CPU. If byte size is 0,
// proceed regardless of memory type as no allocation is required.
if ((memory_type != TRTSERVER_MEMORY_CPU) && (byte_size != 0)) {
LOG_VERBOSE(1) << "GRPC allocation failed for type " << memory_type
<< " for " << tensor_name;
return nullptr; // Success
Expand Down
14 changes: 7 additions & 7 deletions src/servers/http_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,15 @@ HTTPAPIServer::ResponseAlloc(
*buffer = nullptr;
*buffer_userp = nullptr;

// Can't allocate for any memory type other than CPU.
if (memory_type != TRTSERVER_MEMORY_CPU) {
LOG_VERBOSE(1) << "HTTP allocation failed for type " << memory_type
<< " for " << tensor_name;
return nullptr; // Success
}

// Don't need to do anything if no memory was requested.
if (byte_size > 0) {
// Can't allocate for any memory type other than CPU.
if (memory_type != TRTSERVER_MEMORY_CPU) {
LOG_VERBOSE(1) << "HTTP allocation failed for type " << memory_type
<< " for " << tensor_name;
return nullptr; // Success
}

// Reserve requested space in evbuffer...
struct evbuffer_iovec output_iovec;
if (evbuffer_reserve_space(evhttp_buffer, byte_size, &output_iovec, 1) !=
Expand Down

0 comments on commit a2a24d6

Please sign in to comment.