Skip to content

Commit

Permalink
rm CudnnConvDesc and CudnnConvArgs useless constructor (#3480)
Browse files Browse the repository at this point in the history
Co-authored-by: oneflow-bot <[email protected]>
Former-commit-id: 0a85024
  • Loading branch information
leaves-zwx and oneflow-ci-bot authored Aug 14, 2020
1 parent c7b9f35 commit ea1d417
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 70 deletions.
63 changes: 0 additions & 63 deletions oneflow/core/device/cudnn_conv_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,35 +134,6 @@ perf_t GetBestAlgorithm(const CudnnConvArgs& args, CudnnConvResource* res,

CudnnConvDesc::~CudnnConvDesc() { OF_CUDNN_CHECK(cudnnDestroyConvolutionDescriptor(val_)); }

CudnnConvDesc::CudnnConvDesc(const DataType compute_type, const DataType data_type,
const ShapeView& in_blob_shape, const PbMessage& conv_conf) {
int32_t opkernel_dim = in_blob_shape.NumAxes() - 2;
OF_CUDNN_CHECK(cudnnCreateConvolutionDescriptor(&val_));
std::vector<int32_t> pad_large_side;
GetConvOutAndPad(in_blob_shape, conv_conf, nullptr, nullptr, &pad_large_side);
const PbRf<int32_t>& strides = GetPbRfFromPbMessage<int32_t>(conv_conf, "strides");
const PbRf<int32_t>& dilation_rate = GetPbRfFromPbMessage<int32_t>(conv_conf, "dilation_rate");
if (opkernel_dim == 2) {
OF_CUDNN_CHECK(
cudnnSetConvolution2dDescriptor(val_, pad_large_side[0], pad_large_side[1], strides.Get(0),
strides.Get(1), dilation_rate.Get(0), dilation_rate.Get(1),
CUDNN_CROSS_CORRELATION, GetCudnnDataType(compute_type)));
} else if (opkernel_dim == 1) {
OF_CUDNN_CHECK(cudnnSetConvolution2dDescriptor(val_, pad_large_side[0], 0, strides.Get(0), 1,
dilation_rate.Get(0), 1, CUDNN_CROSS_CORRELATION,
GetCudnnDataType(compute_type)));
} else {
OF_CUDNN_CHECK(cudnnSetConvolutionNdDescriptor(
val_, opkernel_dim, pad_large_side.data(), strides.data(), dilation_rate.data(),
CUDNN_CROSS_CORRELATION, GetCudnnDataType(compute_type)));
}
const int32_t groups = GetValFromPbMessage<int32_t>(conv_conf, "groups");
if (groups != 1) { OF_CUDNN_CHECK(cudnnSetConvolutionGroupCount(val_, groups)); }
if (GetCudnnDataType(data_type) == CUDNN_DATA_HALF) {
OF_CUDNN_CHECK(cudnnSetConvolutionMathType(val_, CUDNN_TENSOR_OP_MATH));
}
}

CudnnConvDesc::CudnnConvDesc(const DataType compute_type, const DataType data_type,
const ShapeView& in_blob_shape,
const user_op::UserOpConfWrapper& conv_conf) {
Expand Down Expand Up @@ -192,40 +163,6 @@ CudnnConvDesc::CudnnConvDesc(const DataType compute_type, const DataType data_ty
}
}

CudnnConvArgs::CudnnConvArgs(const PbMessage& conv_conf, DataType x_data_type,
const ShapeView& x_shape, DataType w_data_type,
const ShapeView& w_shape, DataType y_data_type,
const ShapeView& y_shape, const std::string& data_format,
size_t max_workspace_size, bool heuristic_search,
bool use_deterministic_algo_only, bool enable_pseudo_half)
: xdesc(x_data_type, x_shape, data_format),
ydesc(y_data_type, y_shape, data_format),
wdesc(w_data_type, w_shape, data_format),
cdesc(GetConvDescDataType(x_data_type, enable_pseudo_half), x_data_type, x_shape, conv_conf),
heuristic(heuristic_search),
deterministic(use_deterministic_algo_only) {
std::memset(&params, 0, sizeof(CudnnConvParams));
OF_CUDNN_CHECK(cudnnGetTensorNdDescriptor(xdesc.Get(), CudnnConvParams::kTensorMaxDims,
&params.x_data_type, &params.x_ndim, params.x_dims,
params.x_strides));
OF_CUDNN_CHECK(cudnnGetTensorNdDescriptor(ydesc.Get(), CudnnConvParams::kTensorMaxDims,
&params.y_data_type, &params.y_ndim, params.y_dims,
params.y_strides));
OF_CUDNN_CHECK(cudnnGetFilterNdDescriptor(wdesc.Get(), CudnnConvParams::kTensorMaxDims,
&params.w_data_type, &params.w_format, &params.w_ndim,
params.w_dims));
cudnnConvolutionMode_t mode;
int conv_dim_size = 0;
OF_CUDNN_CHECK(cudnnGetConvolutionNdDescriptor(cdesc.Get(), CudnnConvParams::kConvMaxDims,
&conv_dim_size, params.padding, params.stride,
params.dilation, &mode, &params.data_type));
CHECK_EQ(params.x_data_type, params.w_data_type);
CHECK_EQ(params.x_ndim, params.w_ndim);
CHECK_EQ(conv_dim_size + 2, params.x_ndim);
OF_CUDNN_CHECK(cudnnGetConvolutionGroupCount(cdesc.Get(), &params.groups));
params.max_ws_size = max_workspace_size;
}

CudnnConvArgs::CudnnConvArgs(const user_op::UserOpConfWrapper& conv_conf, DataType x_data_type,
const ShapeView& x_shape, DataType w_data_type,
const ShapeView& w_shape, DataType y_data_type,
Expand Down
7 changes: 0 additions & 7 deletions oneflow/core/device/cudnn_conv_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ class CudnnConvDesc final {
CudnnConvDesc() = delete;
~CudnnConvDesc();

CudnnConvDesc(const DataType compute_type, const DataType data_type,
const ShapeView& in_blob_shape, const PbMessage& conv_conf);
CudnnConvDesc(const DataType compute_type, const DataType data_type,
const ShapeView& in_blob_shape, const user_op::UserOpConfWrapper& conv_conf);

Expand Down Expand Up @@ -80,11 +78,6 @@ struct CudnnConvArgs final {
bool deterministic;

OF_DISALLOW_COPY_AND_MOVE(CudnnConvArgs);
CudnnConvArgs(const PbMessage& conv_conf, DataType x_data_type, const ShapeView& x_shape,
DataType w_data_type, const ShapeView& w_shape, DataType y_data_type,
const ShapeView& y_shape, const std::string& data_format, size_t max_workspace_size,
bool heuristic_search, bool use_deterministic_algo_only, bool enable_pseudo_half);

CudnnConvArgs(const user_op::UserOpConfWrapper& conv_conf, DataType x_data_type,
const ShapeView& x_shape, DataType w_data_type, const ShapeView& w_shape,
DataType y_data_type, const ShapeView& y_shape, const std::string& data_format,
Expand Down

0 comments on commit ea1d417

Please sign in to comment.