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

cleaning resize.cpp

parent 2421b81a
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
......@@ -28,8 +28,6 @@ const std::string Aidge::Resize_Op::Type = "Resize";
bool Aidge::Resize_Op::forwardDims(bool /*allowDataDependency*/) {
fmt::print("Resize forward Dims\n");
// check input ("data_input","roi", "scales", "data_input","sizes") has been associated
for (size_t i = 0; i < 4; ++i) {
if (!getInput(i)) {
......@@ -37,65 +35,43 @@ bool Aidge::Resize_Op::forwardDims(bool /*allowDataDependency*/) {
}
}
// roi not implemented
// require scales of the input to have dims defined
// if ((!getInput(0)->empty()) && (getInput(1)->empty() && !getInput(2)->empty() && getInput(3)->empty()) ) {
// fmt::print("Condition scales.\n");
// // condition 1. input data_input tensor + scales
// std::vector<DimSize_t> outDims = getInput(0)->dims();
// fmt::print("input dims 0 = {}\n", outDims);
// fmt::print("input dims 1 = {}\n", getInput(1)->dims());
// fmt::print("input dims 2 = {}\n", getInput(2)->dims());
// fmt::print("input dims 3 = {}\n", getInput(3)->dims());
// printf("Scales Input(1)");
// float* scales = static_cast<float*>(getInput(1)->getImpl()->rawPtr()); //TODO cast according to tensor type
// if ((!getInput(0)->empty()) && !getInput(2)->empty() && this->template getAttr<ResizeAttr::NoROI>() && this->template getAttr<ResizeAttr::NoSizes>()) {
if (this->template getAttr<ResizeAttr::NoROI>() && this->template getAttr<ResizeAttr::NoSizes>()) {
std::vector<DimSize_t> outDims = getInput(0)->dims();
const std::vector<DimSize_t> inDims = getInput(0)->dims();
// /*
// std::vector<DimSize_t> outDims[ width_out = width_input_tensor*scales[3], \
// height_out = heigh_input_tensor*scales[2], \
// depth_input_tensor = depth_input_tensor*scales[1] \
// batch_input_tensor = batch_input_tensor*scales[0] ];
// */
// TODO: cast according to tensor type
float* scales = static_cast<float*>(getInput(2)->getImpl()->rawPtr());
// get values of scales
// for (std::size_t dim=0; dim < getInput(1)->size(); ++dim) {
// // todo verify if batch and depth is not 1 !
// fmt::print("{} {} \n", dim, scales[dim] );
// outDims[dim] *= scales[dim];
// }
// TODO: check if enusure different dims of sizes/scales
for (std::size_t dim=0; dim < getInput(2)->size(); ++dim) {
// TODO: verify if batch and depth is not 1 !/ check if onnx operator impacts scakes
// logic if 1, 2, 2 scales and input tensor 3, 4, 4, !!!
outDims[dim] = inDims[dim]*scales[dim];
}
mOutputs[0]->resize(outDims);
return true;
}
// mOutputs[0]->resize(outDims);
// fmt::print("output dims 0 = {}\n", outDims);
// return true;
// }
// if ((!getInput(0)->empty()) && !getInput(3)->empty() && this->template getAttr<ResizeAttr::NoROI>() && this->template getAttr<ResizeAttr::NoScales>()) {
if (this->template getAttr<ResizeAttr::NoROI>() && this->template getAttr<ResizeAttr::NoScales>()) {
if ((!getInput(0)->empty()) && !getInput(3)->empty() && this->template getAttr<ResizeAttr::NoROI>() && this->template getAttr<ResizeAttr::NoScales>()) {
fmt::print("Condition sizes.\n");
/*
condition 2. input tensor + sizes
condition 2. fmt::print("Condition sizes.\n");
to verify 2 arg
"Input 0 and 2 must be provided and input 1 must not be provided."
"data_input" and "sizes"
*/
*/
std::vector<DimSize_t> outDims = getInput(0)->dims();
fmt::print("input dims 0 = {}\n", outDims);
fmt::print("input dims 1 = {}\n", getInput(1)->dims());
fmt::print("input dims 2 = {}\n", getInput(2)->dims());
fmt::print("input dims 3 = {}\n", getInput(3)->dims());
// printf("Sizes Input(2)\n");
float* sizes = static_cast<float*>(getInput(3)->getImpl()->rawPtr()); //TODO cast according to tensor type
// tmp
const std::vector<DimSize_t> inDims = getInput(0)->dims();
//TODO cast according to tensor type
float* sizes = static_cast<float*>(getInput(3)->getImpl()->rawPtr());
/*
std::vector<DimSize_t> outDims[ width_out = sizes[0], \
......@@ -105,24 +81,15 @@ bool Aidge::Resize_Op::forwardDims(bool /*allowDataDependency*/) {
*/
for (std::size_t dim=0; dim < getInput(3)->size(); ++dim) {
// todo verify if batch and depth is not 1 !
// TODO: verify if batch and depth is not 1 !!!!
outDims[dim] = sizes[dim];
fmt::print("{} {} \n", dim, sizes[dim] );
}
mOutputs[0]->resize(outDims);
fmt::print("output dims 0 = {}\n", outDims);
// fmt::print("Resize forward Dims for sizes. DONE.\n");
return true;
}
// if (!getInput(0)->empty()){
// fmt::print("input 0 not empty\n");
// std::vector<DimSize_t> outDims = getInput(0)->dims();
// fmt::print("input dims 0 = {}\n", outDims);
// fmt::print("input dims 1 = {}\n", getInput(1)->dims());
// fmt::print("input dims 2 = {}\n", getInput(2)->dims());
// fmt::print("input dims 3 = {}\n", getInput(3)->dims());
// }
return false;
}
......
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