Skip to content

Commit 3bbe2b9

Browse files
mc-nvyinggeh
andauthored
post-25.06: Update default branch (#114)
* ci: Fix shape tensor segfault * ci: Update SetDataFromShapeValues implementation after changing shape_values type (#113) --------- Co-authored-by: Yingge He <[email protected]>
1 parent 6b77bc7 commit 3bbe2b9

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/instance_state.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3095,21 +3095,21 @@ ModelInstanceState::InitializeShapeInputBinding(
30953095
: context.max_dims_[io_index].d[0];
30963096
context.max_shapes_[io_index] = ShapeTensor();
30973097
context.max_shapes_[io_index].SetDataFromShapeValues(
3098-
engine_->getProfileTensorValues(
3098+
engine_->getProfileTensorValuesV2(
30993099
input_name.c_str(), profile_index,
31003100
nvinfer1::OptProfileSelector::kMAX),
31013101
input_datatype, context.nb_shape_values_);
31023102

31033103
context.min_shapes_[io_index] = ShapeTensor();
31043104
context.min_shapes_[io_index].SetDataFromShapeValues(
3105-
engine_->getProfileTensorValues(
3105+
engine_->getProfileTensorValuesV2(
31063106
input_name.c_str(), profile_index,
31073107
nvinfer1::OptProfileSelector::kMIN),
31083108
input_datatype, context.nb_shape_values_);
31093109

31103110
context.opt_shapes_[io_index] = ShapeTensor();
31113111
context.opt_shapes_[io_index].SetDataFromShapeValues(
3112-
engine_->getProfileTensorValues(
3112+
engine_->getProfileTensorValuesV2(
31133113
input_name.c_str(), profile_index,
31143114
nvinfer1::OptProfileSelector::kOPT),
31153115
input_datatype, context.nb_shape_values_);

src/model_state.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ ModelState::GetProfileMaxBatchSize(
708708
}
709709

710710
} else {
711-
const int32_t* max_shapes = engine->getProfileTensorValues(
711+
const int64_t* max_shapes = engine->getProfileTensorValuesV2(
712712
tensor_name.c_str(), profile_index,
713713
nvinfer1::OptProfileSelector::kMAX);
714714
if (*max_batch_size > *max_shapes) {

src/shape_tensor.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ ShapeTensor::SetDataFromBuffer(
8888

8989
TRITONSERVER_Error*
9090
ShapeTensor::SetDataFromShapeValues(
91-
const int32_t* shape_values, TRITONSERVER_DataType datatype,
91+
const int64_t* shape_values, TRITONSERVER_DataType datatype,
9292
size_t nb_shape_values)
9393
{
9494
nb_shape_values_ = nb_shape_values;
@@ -99,14 +99,14 @@ ShapeTensor::SetDataFromShapeValues(
9999
datatype_ = ShapeTensorDataType::INT32;
100100
data_.reset(new char[size_]);
101101
int32_t* data_ptr = reinterpret_cast<int32_t*>(data_.get());
102-
std::memcpy(data_ptr, shape_values, size_);
102+
for (size_t i = 0; i < nb_shape_values_; ++i) {
103+
data_ptr[i] = static_cast<int32_t>(shape_values[i]);
104+
}
103105
} else if (datatype == TRITONSERVER_DataType::TRITONSERVER_TYPE_INT64) {
104106
datatype_ = ShapeTensorDataType::INT64;
105107
data_.reset(new char[size_]);
106108
int64_t* data_ptr = reinterpret_cast<int64_t*>(data_.get());
107-
for (size_t i = 0; i < nb_shape_values_; ++i) {
108-
data_ptr[i] = static_cast<int64_t>(shape_values[i]);
109-
}
109+
std::memcpy(data_ptr, shape_values, size_);
110110
} else {
111111
return TRITONSERVER_ErrorNew(
112112
TRITONSERVER_ERROR_INVALID_ARG,

src/shape_tensor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
// Copyright 2024-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
//
33
// Redistribution and use in source and binary forms, with or without
44
// modification, are permitted provided that the following conditions
@@ -51,7 +51,7 @@ class ShapeTensor {
5151
const char* input_name, bool support_batching, size_t total_batch_size);
5252

5353
TRITONSERVER_Error* SetDataFromShapeValues(
54-
const int32_t* shape_values, TRITONSERVER_DataType datatype,
54+
const int64_t* shape_values, TRITONSERVER_DataType datatype,
5555
size_t nb_shape_values);
5656

5757
int64_t GetDistance(const ShapeTensor& other, int64_t total_batch_size) const;

0 commit comments

Comments
 (0)