diff --git a/cmake/operators.cmake b/cmake/operators.cmake index 34b4536e4e2795a9b51c4855cb1ee66f54a57758..d3d35cb3ae7e5670f040566cd19237997de1de73 100644 --- a/cmake/operators.cmake +++ b/cmake/operators.cmake @@ -105,9 +105,6 @@ function(op_library TARGET) ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.cu) list(APPEND cu_srcs ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.cu) endif() - if(WITH_NV_JETSON) - list(REMOVE_ITEM cu_srcs "decode_jpeg_op.cu") - endif() if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}.part.cu) set(PART_CUDA_KERNEL_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}.part.cu @@ -308,7 +305,6 @@ function(op_library TARGET) list(REMOVE_ITEM hip_srcs "eigh_op.cu") list(REMOVE_ITEM hip_srcs "lstsq_op.cu") list(REMOVE_ITEM hip_srcs "multinomial_op.cu") - list(REMOVE_ITEM hip_srcs "decode_jpeg_op.cu") hip_library( ${TARGET} SRCS ${cc_srcs} ${hip_cc_srcs} ${miopen_cu_cc_srcs} ${miopen_cu_srcs} diff --git a/paddle/fluid/operators/decode_jpeg_op.cc b/paddle/fluid/operators/decode_jpeg_op.cc deleted file mode 100644 index 43fefd4dd17343325f32af4c7a171f43e0b510a1..0000000000000000000000000000000000000000 --- a/paddle/fluid/operators/decode_jpeg_op.cc +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include - -#include "paddle/fluid/framework/infershape_utils.h" -#include "paddle/fluid/framework/op_registry.h" -#include "paddle/fluid/framework/operator.h" -#include "paddle/fluid/platform/enforce.h" -#include "paddle/phi/core/generator.h" -#include "paddle/phi/core/infermeta_utils.h" -#include "paddle/phi/infermeta/unary.h" - -namespace paddle { -namespace operators { - -class DecodeJpegOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - return phi::KernelKey(OperatorWithKernel::IndicateVarDataType(ctx, "X"), - ctx.GetPlace()); - } - - phi::KernelKey GetKernelTypeForVar( - const std::string& var_name, - const phi::DenseTensor& tensor, - const phi::KernelKey& expected_kernel_type) const override { - if (var_name == "X") { - return phi::KernelKey(phi::Backend::ALL_BACKEND, - expected_kernel_type.layout(), - expected_kernel_type.dtype()); - } - - return phi::KernelKey(tensor.place(), tensor.layout(), tensor.dtype()); - } -}; - -class DecodeJpegOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", - "A one dimensional uint8 tensor containing the raw bytes " - "of the JPEG image. It is a tensor with rank 1."); - AddOutput("Out", "The output tensor of DecodeJpeg op"); - AddComment(R"DOC( -This operator decodes a JPEG image into a 3 dimensional RGB Tensor -or 1 dimensional Gray Tensor. Optionally converts the image to the -desired format. The values of the output tensor are uint8 between 0 -and 255. -)DOC"); - AddAttr( - "mode", - "(string, default \"unchanged\"), The read mode used " - "for optionally converting the image, can be \"unchanged\" " - ",\"gray\" , \"rgb\" .") - .SetDefault("unchanged"); - } -}; - -} // namespace operators -} // namespace paddle - -namespace ops = paddle::operators; -DECLARE_INFER_SHAPE_FUNCTOR(decode_jpeg, - DecodeJpegInferShapeFunctor, - PD_INFER_META(phi::DecodeJpegInferMeta)); - -REGISTER_OPERATOR( - decode_jpeg, - ops::DecodeJpegOp, - ops::DecodeJpegOpMaker, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - DecodeJpegInferShapeFunctor) diff --git a/paddle/phi/api/yaml/op_compat.yaml b/paddle/phi/api/yaml/op_compat.yaml index cacac7dfb9ffb5c76fb498a9f2712f6c5d73ed9c..2cac5acfe9ab103ed5fb7bdbd7ee4affb4fc2b64 100644 --- a/paddle/phi/api/yaml/op_compat.yaml +++ b/paddle/phi/api/yaml/op_compat.yaml @@ -448,6 +448,12 @@ extra : attrs : [bool use_mkldnn = false] +- op : decode_jpeg + inputs : + x : X + outputs : + out : Out + - op : depthwise_conv2d backward : depthwise_conv2d_grad extra : diff --git a/paddle/phi/api/yaml/static_ops.yaml b/paddle/phi/api/yaml/static_ops.yaml index 8f9201d7ec4bf451ea362d1988e3d56e2638b7c5..482afab7fd24df8324ece4333e4624878c51d910 100644 --- a/paddle/phi/api/yaml/static_ops.yaml +++ b/paddle/phi/api/yaml/static_ops.yaml @@ -57,6 +57,16 @@ func : broadcast param: [x, root] +- op : decode_jpeg + args : (Tensor x, str mode = "unchanged") + output : Tensor(out) + infer_meta : + func : DecodeJpegInferMeta + param : [x, mode] + kernel : + func : decode_jpeg + param : [x, mode] + - op : embedding args : (Tensor x, Tensor weight, int64_t padding_idx=-1) output : Tensor diff --git a/paddle/phi/ops/compat/decode_jpeg_sig.cc b/paddle/phi/ops/compat/decode_jpeg_sig.cc deleted file mode 100644 index 8c3d2399caeccdb2e6366782b393c6b0d4cc4bdc..0000000000000000000000000000000000000000 --- a/paddle/phi/ops/compat/decode_jpeg_sig.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "paddle/phi/core/compat/op_utils.h" - -namespace phi { - -KernelSignature DecodeJpegOpArgumentMapping(const ArgumentMappingContext& ctx) { - return KernelSignature("decode_jpeg", {"X"}, {"mode"}, {"Out"}); -} - -} // namespace phi - -PD_REGISTER_ARG_MAPPING_FN(decode_jpeg, phi::DecodeJpegOpArgumentMapping);