diff --git a/python_binding/operator/pybind_Resize.cpp b/python_binding/operator/pybind_Resize.cpp index 8a8a968bb34383053faaaced9230487814ab5dde..9aa0ae9548309b75ec75a5927af0db025331cace 100644 --- a/python_binding/operator/pybind_Resize.cpp +++ b/python_binding/operator/pybind_Resize.cpp @@ -24,6 +24,6 @@ void init_Resize(py::module& m) { declare_registrable<Resize_Op>(m, "ResizeOp"); - m.def("Resize", &Resize, py::arg("nb_input_dims"), py::arg("no_roi"), py::arg("no_scales"), py::arg("no_sizes"), py::arg("name") = ""); + m.def("Resize", &Resize, py::arg("name") = ""); } } // namespace Aidge diff --git a/src/operator/Resize.cpp b/src/operator/Resize.cpp index 597cbaf9e96022b8c0ec5bbac03bc18fa6338471..b4638ce9a8e5b2ebd67ecd55eb9c24decda0557d 100644 --- a/src/operator/Resize.cpp +++ b/src/operator/Resize.cpp @@ -53,26 +53,23 @@ bool Aidge::Resize_Op::forwardDims(bool allowDataDependency) { return false; } - if (getInput(1) && !getInput(1)->empty()) { - AIDGE_THROW_OR_ABORT(std::runtime_error, "ROI input is not supported"); - return false; - } + bool input1ROIPresent = getInput(1) && !getInput(1)->empty(); + bool input2ScalesPresent = getInput(2) && !getInput(2)->empty(); + bool input3SizesPresent = getInput(3) && !getInput(3)->empty(); - if (getInput(2) && !getInput(2)->empty()) { + if (input1ROIPresent) { - /* - fmt::print("Condition scales: Input#0 and Input#2 must be provided and must have the same dimension,\ - while Inputs#1 and #3 must not be provided.\n"); - */ + AIDGE_THROW_OR_ABORT(std::runtime_error, "Input #1 (ROI) is given and it is not supported."); + + } else if (input2ScalesPresent) { if (!allowDataDependency) { - Log::warn("Resize_Op: unable to forwardDims() because output dims are data dependent\ - on input#0 and input#2"); + Log::warn("Resize_Op: cannot execute forwardDims() as the output dimensions depend on the input #2"); return false; } AIDGE_ASSERT(getInput(0)->nbDims() == getInput(2)->size(),\ - "input tensor and Scales must have the same dimensions."); + "input #0 and input #2 (Scales) must have the same dimensions."); std::vector<DimSize_t> outDims = getInput(0)->dims(); const std::vector<DimSize_t> inDims = getInput(0)->dims(); @@ -83,26 +80,20 @@ bool Aidge::Resize_Op::forwardDims(bool allowDataDependency) { for (std::size_t dim=0; dim < getInput(2)->size(); ++dim) { outDims[dim] = inDims[dim]*static_cast<int64_t*>(scales.getImpl()->hostPtr())[dim]; } + mOutputs[0]->resize(outDims); return true; - } - - if (getInput(3) && !getInput(3)->empty()) { - /* - fmt::print("Condition sizes: Input#0 and Input#3 must be provided and must have the same dimension,\ - while Inputs#1 and #2 must not be provided.\n"); - */ + } else if (input3SizesPresent) { if (!allowDataDependency) { - Log::warn("Resize_Op: unable to forwardDims() because output dims are data dependent\ - on input#0 and input#3)"); + Log::warn("Resize_Op: cannot execute forwardDims() as the output dimensions depend on the input #3"); return false; } AIDGE_ASSERT(getInput(0)->nbDims() == getInput(3)->size(),\ - "input tensor and Sizes must have the same dimensions."); + "input #0 and input #3 (Sizes) must have the same dimensions."); std::vector<DimSize_t> outDims = getInput(0)->dims(); @@ -112,12 +103,15 @@ bool Aidge::Resize_Op::forwardDims(bool allowDataDependency) { for (std::size_t dim=0; dim < getInput(3)->size(); ++dim) { outDims[dim] = static_cast<int64_t*>(sizes.getImpl()->hostPtr())[dim]; } + mOutputs[0]->resize(outDims); return true; + } else { + AIDGE_THROW_OR_ABORT(std::runtime_error, "Error: Either Input #2 or Input #3 must be present."); } - return false; + return false; } void Aidge::Resize_Op::setBackend(const std::string& name, Aidge::DeviceIdx_t device) {