Skip to content

Commit c705c84

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into develop
2 parents ed9a69f + 04a49b0 commit c705c84

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2339
-1402
lines changed

paddle/fluid/framework/CMakeLists.txt

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -360,46 +360,11 @@ set(FLUID_FRAMEWORK_MODULES proto_desc memory lod_tensor executor data_feed_prot
360360

361361
cc_library(paddle_framework DEPS ${FLUID_FRAMEWORK_MODULES})
362362

363-
# Old custom op extension mechanism related, will be removed in 2.1.0
364-
cc_library(paddle_framework_shared
365-
SHARED SRCS executor.cc operator.cc
366-
${CMAKE_CURRENT_SOURCE_DIR}/c/c_api.cc
367-
${CMAKE_SOURCE_DIR}/paddle/fluid/imperative/layer.cc
368-
DEPS ${FLUID_FRAMEWORK_MODULES})
369-
get_property(os_dependency_modules GLOBAL PROPERTY OS_DEPENDENCY_MODULES)
370-
set_target_properties(paddle_framework_shared PROPERTIES OUTPUT_NAME paddle_framework)
371-
target_link_libraries(paddle_framework_shared ${os_dependency_modules})
372-
373-
if (LINUX)
374-
set(FLUID_FRAMEWORK_SHARED_LIB
375-
${PADDLE_BINARY_DIR}/paddle/fluid/framework/libpaddle_framework.so
376-
CACHE INTERNAL "Fluid framework lib")
377-
endif()
378-
379-
if (WIN32)
380-
if("${CMAKE_GENERATOR}" STREQUAL "Ninja")
381-
set(paddle_framework_lib_path ${CMAKE_CURRENT_BINARY_DIR})
382-
else()
383-
set(paddle_framework_lib_path ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
384-
endif()
385-
set(FLUID_FRAMEWORK_IMPORT_LIB
386-
${paddle_framework_lib_path}/paddle_framework.lib
387-
CACHE INTERNAL "Fluid framework lib")
388-
set(FLUID_FRAMEWORK_SHARED_LIB
389-
${paddle_framework_lib_path}/paddle_framework.dll
390-
CACHE INTERNAL "Fluid framework dll")
391-
endif()
392-
393-
if(APPLE)
394-
set(FLUID_FRAMEWORK_SHARED_LIB
395-
${PADDLE_BINARY_DIR}/paddle/fluid/framework/libpaddle_framework.dylib
396-
CACHE INTERNAL "Fluid framework lib")
397-
endif()
398363
if(WITH_TESTING AND TEST selected_rows_test)
399364
set_tests_properties(selected_rows_test PROPERTIES TIMEOUT 120)
400365
endif()
401366

402-
# New custom op extension mechanism related
367+
##### 2.0 New custom op extension mechanism related #####
403368

404369
# if not deps `layer`, will cause: undefined symbol: _ZN6paddle10imperative7VarBase9name_set_
405370
set(PADDLE_CUSTOM_OP_MODULES custom_tensor op_meta_info custom_operator layer)

paddle/fluid/framework/c/c_api.cc

Lines changed: 0 additions & 53 deletions
This file was deleted.

paddle/fluid/framework/c/c_api.h

Lines changed: 0 additions & 55 deletions
This file was deleted.

paddle/fluid/framework/load_op_lib.h

Lines changed: 0 additions & 120 deletions
This file was deleted.

paddle/fluid/inference/api/analysis_predictor.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,6 +1192,7 @@ USE_TRT_CONVERTER(scale);
11921192
USE_TRT_CONVERTER(stack);
11931193
USE_TRT_CONVERTER(clip);
11941194
USE_TRT_CONVERTER(gather);
1195+
USE_TRT_CONVERTER(yolo_box);
11951196
USE_TRT_CONVERTER(roi_align);
11961197
USE_TRT_CONVERTER(affine_channel);
11971198
USE_TRT_CONVERTER(multiclass_nms);

paddle/fluid/inference/tensorrt/convert/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ nv_library(tensorrt_converter
66
shuffle_channel_op.cc swish_op.cc instance_norm_op.cc stack_op.cc transpose_op.cc flatten_op.cc
77
emb_eltwise_layernorm.cc skip_layernorm.cc scale_op.cc slice_op.cc hard_sigmoid_op.cc hard_swish_op.cc clip_op.cc
88
gather_op.cc
9+
yolo_box_op.cc
910
roi_align_op.cc
1011
affine_channel_op.cc
1112
multiclass_nms_op.cc

paddle/fluid/inference/tensorrt/convert/batch_norm_op.cc

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,49 @@ class BatchNormOpConverter : public OpConverter {
158158
TensorRTEngine::Weight power_weights{nvinfer1::DataType::kFLOAT, nullptr,
159159
0};
160160

161-
nvinfer1::IScaleLayer* layer =
162-
TRT_ENGINE_ADD_LAYER(engine_, Scale, *const_cast<nvinfer1::ITensor*>(X),
163-
nvinfer1::ScaleMode::kCHANNEL, shift_weights.get(),
164-
scale_weights.get(), power_weights.get());
161+
int dynamic_shape_offset = engine_->with_dynamic_shape() ? 1 : 0;
162+
nvinfer1::ILayer* layer = nullptr;
163+
nvinfer1::IShuffleLayer* expand_layer = nullptr;
164+
nvinfer1::IShuffleLayer* squeeze_layer = nullptr;
165+
166+
auto x_dim = X->getDimensions();
167+
if (x_dim.nbDims < 3 + dynamic_shape_offset) {
168+
nvinfer1::Dims expand_shape;
169+
expand_shape.nbDims = 3 + dynamic_shape_offset;
170+
for (int i = 0; i < 3 + dynamic_shape_offset; i++) {
171+
if (i < x_dim.nbDims) {
172+
expand_shape.d[i] = x_dim.d[i] < 0 ? 0 : x_dim.d[i];
173+
} else {
174+
expand_shape.d[i] = 1;
175+
}
176+
}
177+
expand_layer = TRT_ENGINE_ADD_LAYER(engine_, Shuffle, *X);
178+
expand_layer->setReshapeDimensions(expand_shape);
179+
X = expand_layer->getOutput(0);
180+
}
181+
182+
layer = TRT_ENGINE_ADD_LAYER(
183+
engine_, Scale, *X, nvinfer1::ScaleMode::kCHANNEL, shift_weights.get(),
184+
scale_weights.get(), power_weights.get());
165185

166186
auto output_name = op_desc.Output("Y").front();
167187
engine_->SetWeights(op_desc.Input("Bias").front(),
168188
std::move(combile_bias_tensor));
169189
engine_->SetWeights(op_desc.Input("Scale").front(),
170190
std::move(combile_scale_tensor));
171-
RreplenishLayerAndOutput(layer, "pool2d", {output_name}, test_mode);
191+
if (x_dim.nbDims < 3 + dynamic_shape_offset) {
192+
nvinfer1::Dims squeeze_shape;
193+
squeeze_shape.nbDims = x_dim.nbDims;
194+
for (int i = 0; i < squeeze_shape.nbDims; i++) {
195+
squeeze_shape.d[i] = x_dim.d[i] < 0 ? 0 : x_dim.d[i];
196+
}
197+
squeeze_layer =
198+
TRT_ENGINE_ADD_LAYER(engine_, Shuffle, *(layer->getOutput(0)));
199+
squeeze_layer->setReshapeDimensions(squeeze_shape);
200+
layer = static_cast<nvinfer1::ILayer*>(squeeze_layer);
201+
}
202+
RreplenishLayerAndOutput(layer, "batchnorm_add_scale", {output_name},
203+
test_mode);
172204
}
173205
};
174206

0 commit comments

Comments
 (0)