* Refactored resize images ops to use TF-like bool args as input. * Refactored helpers for cpu implementation of resize_bilinear and resize_nearest_neighbor ops. * Refactored cuda implementation for image.resize_bilinear and image.resize_nearest_neighbor ops helpers. * Refactored nearest_neighbor resize op. * Added a pair of tests for special case of resize_bilinear algorithm. * Fixed issue with resize_bilinear op. * Refactored cpu implementation for helpers with resize_nearest_neighbor op. * Final fixed for resize ops to conform TF v.1.5 * Refactored cuda helpers for resize_neares_neighbor op. * Fixed resize_bilinear to accept proper data. * Fixed issue with non-float input for resize_bilinear op. * Refactored cuda helper for resize_bilinear to proper process non-float inputs. * Added tests for resize_bilinear to int inputs. * Fixed ResizeBilinear wrapper * Tests fixed * Fixed float and bool constant to avoid overflow for some kind of compilers. * Corrected float constants with float data type. * Added f suffix for float constants. * Corrected float constant to avoid overflow with initializing lists. * Corrected float initializing list with float input. * Corrected bool constant with initalizing list. * Corrected float and bool values with initializing lists. * Fixed wrong constant. * Fixed issue with 1x1 input picture for resize. * ResizeBilinear default values on import fix Signed-off-by: raver119 <raver119@gmail.com>
57 lines
2.4 KiB
C++
57 lines
2.4 KiB
C++
/*******************************************************************************
|
|
* Copyright (c) 2015-2018 Skymind, Inc.
|
|
* Copyright (c) 2019 Konduit K.K.
|
|
*
|
|
* This program and the accompanying materials are made available under the
|
|
* terms of the Apache License, Version 2.0 which is available at
|
|
* https://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.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
******************************************************************************/
|
|
|
|
//
|
|
// @author sgazeos@gmail.com
|
|
//
|
|
#ifndef __IMAGE_RESIZE_HELPERS__
|
|
#define __IMAGE_RESIZE_HELPERS__
|
|
#include <op_boilerplate.h>
|
|
#include <NDArray.h>
|
|
|
|
namespace nd4j {
|
|
namespace ops {
|
|
namespace helpers {
|
|
|
|
enum ImageResizeMethods {
|
|
kResizeBilinear = 1,
|
|
kResizeBicubic,
|
|
kResizeNearest,
|
|
kResizeGaussian,
|
|
kResizeLanczos5,
|
|
kResizeMitchelcubic,
|
|
kResizeArea
|
|
};
|
|
|
|
int resizeBilinearFunctor(nd4j::LaunchContext * context, NDArray const* image, int const width, int const height,
|
|
bool const alignCorners, bool const halfPixelCenter, NDArray* output);
|
|
int resizeNeighborFunctor(nd4j::LaunchContext * context, NDArray const* image, int const width, int const height,
|
|
bool const alignCorners, bool const halfPixelCenter, NDArray* output);
|
|
int resizeBicubicFunctor(nd4j::LaunchContext * context, NDArray const* image, int const width, int const height,
|
|
bool preserveAspectRatio, bool antialias, NDArray* output);
|
|
int resizeBicubicFunctorA(nd4j::LaunchContext * context, NDArray const* image, int const width, int const height,
|
|
bool const alignCorners, bool const halfPixelAlign, NDArray* output);
|
|
int resizeFunctor(nd4j::LaunchContext * context, NDArray const* image, int const width, int const height,
|
|
ImageResizeMethods method, bool preserveAspectRatio, bool antialias, NDArray* output);
|
|
|
|
void cropAndResizeFunctor(nd4j::LaunchContext * context, NDArray const* images, NDArray const* boxes,
|
|
NDArray const* indices, NDArray const* cropSize, int method, double extrapolationVal, NDArray* crops);
|
|
}
|
|
}
|
|
}
|
|
#endif
|