Skip to content
Snippets Groups Projects
Commit c60708b2 authored by Michal Szczepanski's avatar Michal Szczepanski
Browse files

asserts added for null imputs

parent b776dd1a
No related branches found
No related tags found
2 merge requests!152Update Aidge export to take a graph view has an argument instead of a...,!125Operator resize
......@@ -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
......@@ -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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment