Skip to content

Commit d69c60b

Browse files
authored
Properly remove first 4 bytes of BYTES data (#550)
* Add plumbing to get output datatype * ignore first 4 bytes of BYTES data for gathering output * Update py code to no longer remove leading bytes * remove workaround in tests * Fix order of args * more fixes * handle case where bytes response is empty
1 parent dcc01dd commit d69c60b

19 files changed

+92
-78
lines changed

src/c++/library/common.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,9 @@ InferInput::GetNext(
279279
Error
280280
InferRequestedOutput::Create(
281281
InferRequestedOutput** infer_output, const std::string& name,
282-
const size_t class_count)
282+
const size_t class_count, const std::string& datatype)
283283
{
284-
*infer_output = new InferRequestedOutput(name, class_count);
284+
*infer_output = new InferRequestedOutput(name, datatype, class_count);
285285
return Error::Success;
286286
}
287287

@@ -309,8 +309,10 @@ InferRequestedOutput::UnsetSharedMemory()
309309
}
310310

311311
InferRequestedOutput::InferRequestedOutput(
312-
const std::string& name, const size_t class_count)
313-
: name_(name), class_count_(class_count), io_type_(NONE)
312+
const std::string& name, const std::string& datatype,
313+
const size_t class_count)
314+
: name_(name), datatype_(datatype), class_count_(class_count),
315+
io_type_(NONE)
314316
{
315317
}
316318

src/c++/library/common.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ class InferRequestedOutput {
400400
/// \return Error object indicating success or failure.
401401
static Error Create(
402402
InferRequestedOutput** infer_output, const std::string& name,
403-
const size_t class_count = 0);
403+
const size_t class_count = 0, const std::string& datatype = "");
404404

405405
/// Gets name of the associated output tensor.
406406
/// \return The name of the tensor.
@@ -455,9 +455,11 @@ class InferRequestedOutput {
455455
#endif
456456

457457
explicit InferRequestedOutput(
458-
const std::string& name, const size_t class_count = 0);
458+
const std::string& name, const std::string& datatype,
459+
const size_t class_count = 0);
459460

460461
std::string name_;
462+
std::string datatype_;
461463
size_t class_count_;
462464

463465
// Used only if working with Shared Memory

src/c++/perf_analyzer/client_backend/client_backend.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -519,16 +519,17 @@ InferInput::InferInput(
519519
Error
520520
InferRequestedOutput::Create(
521521
InferRequestedOutput** infer_output, const BackendKind kind,
522-
const std::string& name, const size_t class_count)
522+
const std::string& name, const std::string& datatype,
523+
const size_t class_count)
523524
{
524525
if (kind == TRITON) {
525526
RETURN_IF_CB_ERROR(tritonremote::TritonInferRequestedOutput::Create(
526-
infer_output, name, class_count));
527+
infer_output, name, class_count, datatype));
527528
}
528529
#ifdef TRITON_ENABLE_PERF_ANALYZER_OPENAI
529530
else if (kind == OPENAI) {
530-
RETURN_IF_CB_ERROR(
531-
openai::OpenAiInferRequestedOutput::Create(infer_output, name));
531+
RETURN_IF_CB_ERROR(openai::OpenAiInferRequestedOutput::Create(
532+
infer_output, name, datatype));
532533
}
533534
#endif // TRITON_ENABLE_PERF_ANALYZER_OPENAI
534535
#ifdef TRITON_ENABLE_PERF_ANALYZER_TFS
@@ -540,7 +541,7 @@ InferRequestedOutput::Create(
540541
#ifdef TRITON_ENABLE_PERF_ANALYZER_C_API
541542
else if (kind == TRITON_C_API) {
542543
RETURN_IF_CB_ERROR(tritoncapi::TritonCApiInferRequestedOutput::Create(
543-
infer_output, name, class_count));
544+
infer_output, name, class_count, datatype));
544545
}
545546
#endif // TRITON_ENABLE_PERF_ANALYZER_C_API
546547
else {
@@ -564,8 +565,9 @@ InferRequestedOutput::SetSharedMemory(
564565
}
565566

566567
InferRequestedOutput::InferRequestedOutput(
567-
const BackendKind kind, const std::string& name)
568-
: kind_(kind), name_(name)
568+
const BackendKind kind, const std::string& name,
569+
const std::string& datatype)
570+
: kind_(kind), name_(name), datatype_(datatype)
569571
{
570572
}
571573

src/c++/perf_analyzer/client_backend/client_backend.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,18 +581,24 @@ class InferRequestedOutput {
581581
/// \param infer_output Returns a new InferOutputGrpc object.
582582
/// \param kind The kind of the associated client backend.
583583
/// \param name The name of output being requested.
584+
/// \param datatype The datatype of the output
584585
/// \param class_count The number of classifications to be requested. The
585586
/// default value is 0 which means the classification results are not
586587
/// requested.
587588
/// \return Error object indicating success or failure.
588589
static Error Create(
589590
InferRequestedOutput** infer_output, const BackendKind kind,
590-
const std::string& name, const size_t class_count = 0);
591+
const std::string& name, const std::string& datatype,
592+
const size_t class_count = 0);
591593

592594
/// Gets name of the associated output tensor.
593595
/// \return The name of the tensor.
594596
const std::string& Name() const { return name_; }
595597

598+
/// Gets datatype of the associated output tensor.
599+
/// \return The datatype of the tensor
600+
const std::string& Datatype() const { return datatype_; }
601+
596602
/// Set the output tensor data to be written to specified shared
597603
/// memory region.
598604
/// \param region_name The name of the shared memory region.
@@ -605,9 +611,12 @@ class InferRequestedOutput {
605611
const size_t offset = 0);
606612

607613
protected:
608-
InferRequestedOutput(const BackendKind kind, const std::string& name);
614+
InferRequestedOutput(
615+
const BackendKind kind, const std::string& name,
616+
const std::string& datatype = "");
609617
const BackendKind kind_;
610618
const std::string name_;
619+
const std::string datatype_;
611620
};
612621

613622
//

src/c++/perf_analyzer/client_backend/openai/openai_client_backend.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,25 @@ OpenAiClientBackend::ClientInferStat(InferStat* infer_stat)
8383

8484
Error
8585
OpenAiInferRequestedOutput::Create(
86-
InferRequestedOutput** infer_output, const std::string& name)
86+
InferRequestedOutput** infer_output, const std::string& name,
87+
const std::string& datatype)
8788
{
8889
OpenAiInferRequestedOutput* local_infer_output =
89-
new OpenAiInferRequestedOutput(name);
90+
new OpenAiInferRequestedOutput(name, datatype);
9091

9192
tc::InferRequestedOutput* openai_infer_output;
92-
RETURN_IF_TRITON_ERROR(
93-
tc::InferRequestedOutput::Create(&openai_infer_output, name));
93+
RETURN_IF_TRITON_ERROR(tc::InferRequestedOutput::Create(
94+
&openai_infer_output, name, 0, datatype));
9495
local_infer_output->output_.reset(openai_infer_output);
9596

9697
*infer_output = local_infer_output;
9798

9899
return Error::Success;
99100
}
100101

101-
OpenAiInferRequestedOutput::OpenAiInferRequestedOutput(const std::string& name)
102-
: InferRequestedOutput(BackendKind::OPENAI, name)
102+
OpenAiInferRequestedOutput::OpenAiInferRequestedOutput(
103+
const std::string& name, const std::string& datatype)
104+
: InferRequestedOutput(BackendKind::OPENAI, name, datatype)
103105
{
104106
}
105107

src/c++/perf_analyzer/client_backend/openai/openai_client_backend.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,15 @@ class OpenAiClientBackend : public ClientBackend {
9595
class OpenAiInferRequestedOutput : public InferRequestedOutput {
9696
public:
9797
static Error Create(
98-
InferRequestedOutput** infer_output, const std::string& name);
98+
InferRequestedOutput** infer_output, const std::string& name,
99+
const std::string& datatype);
99100
/// Returns the raw InferRequestedOutput object required by OpenAi client
100101
/// library.
101102
tc::InferRequestedOutput* Get() const { return output_.get(); }
102103

103104
private:
104-
explicit OpenAiInferRequestedOutput(const std::string& name);
105+
explicit OpenAiInferRequestedOutput(
106+
const std::string& name, const std::string& datatype);
105107

106108
std::unique_ptr<tc::InferRequestedOutput> output_;
107109
};

src/c++/perf_analyzer/client_backend/triton/triton_client_backend.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -768,14 +768,14 @@ TritonInferInput::TritonInferInput(
768768
Error
769769
TritonInferRequestedOutput::Create(
770770
InferRequestedOutput** infer_output, const std::string& name,
771-
const size_t class_count)
771+
const size_t class_count, const std::string& datatype)
772772
{
773773
TritonInferRequestedOutput* local_infer_output =
774-
new TritonInferRequestedOutput(name);
774+
new TritonInferRequestedOutput(name, datatype);
775775

776776
tc::InferRequestedOutput* triton_infer_output;
777777
RETURN_IF_TRITON_ERROR(tc::InferRequestedOutput::Create(
778-
&triton_infer_output, name, class_count));
778+
&triton_infer_output, name, class_count, datatype));
779779
local_infer_output->output_.reset(triton_infer_output);
780780

781781
*infer_output = local_infer_output;
@@ -793,8 +793,9 @@ TritonInferRequestedOutput::SetSharedMemory(
793793
}
794794

795795

796-
TritonInferRequestedOutput::TritonInferRequestedOutput(const std::string& name)
797-
: InferRequestedOutput(BackendKind::TRITON, name)
796+
TritonInferRequestedOutput::TritonInferRequestedOutput(
797+
const std::string& name, const std::string& datatype)
798+
: InferRequestedOutput(BackendKind::TRITON, name, datatype)
798799
{
799800
}
800801

src/c++/perf_analyzer/client_backend/triton/triton_client_backend.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ class TritonInferRequestedOutput : public InferRequestedOutput {
299299
public:
300300
static Error Create(
301301
InferRequestedOutput** infer_output, const std::string& name,
302-
const size_t class_count = 0);
302+
const size_t class_count = 0, const std::string& datatype = "");
303303
/// Returns the raw InferRequestedOutput object required by triton client
304304
/// library.
305305
tc::InferRequestedOutput* Get() const { return output_.get(); }
@@ -309,7 +309,8 @@ class TritonInferRequestedOutput : public InferRequestedOutput {
309309
const size_t offset = 0) override;
310310

311311
private:
312-
explicit TritonInferRequestedOutput(const std::string& name);
312+
explicit TritonInferRequestedOutput(
313+
const std::string& name, const std::string& datatype);
313314

314315
std::unique_ptr<tc::InferRequestedOutput> output_;
315316
};

src/c++/perf_analyzer/client_backend/triton_c_api/triton_c_api_backend.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,14 +335,14 @@ TritonCApiInferInput::TritonCApiInferInput(
335335
Error
336336
TritonCApiInferRequestedOutput::Create(
337337
InferRequestedOutput** infer_output, const std::string& name,
338-
const size_t class_count)
338+
const size_t class_count, const std::string& datatype)
339339
{
340340
TritonCApiInferRequestedOutput* local_infer_output =
341341
new TritonCApiInferRequestedOutput(name);
342342

343343
tc::InferRequestedOutput* triton_infer_output;
344344
RETURN_IF_TRITON_ERROR(tc::InferRequestedOutput::Create(
345-
&triton_infer_output, name, class_count));
345+
&triton_infer_output, name, class_count, datatype));
346346
local_infer_output->output_.reset(triton_infer_output);
347347

348348
*infer_output = local_infer_output;

src/c++/perf_analyzer/client_backend/triton_c_api/triton_c_api_backend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class TritonCApiInferRequestedOutput : public InferRequestedOutput {
186186
public:
187187
static Error Create(
188188
InferRequestedOutput** infer_output, const std::string& name,
189-
const size_t class_count = 0);
189+
const size_t class_count = 0, const std::string& datatype = "");
190190
/// Returns the raw InferRequestedOutput object required by triton client
191191
/// library.
192192
tc::InferRequestedOutput* Get() const { return output_.get(); }

0 commit comments

Comments
 (0)