@@ -12,18 +12,6 @@ ResizeNearestNeighbor::ResizeNearestNeighbor(int operationIndex) : OperationsBas
1212}
1313
1414bool ResizeNearestNeighbor::validate () {
15- // TODO Add FLOAT16 check when VPUX plugin is supported
16- if (!checkOutputOperandType (0 , (int32_t )OperandType::TENSOR_FLOAT32 ) &&
17- !checkOutputOperandType (0 , (int32_t )OperandType::TENSOR_QUANT8_ASYMM )) {
18- ALOGE (" %s check for output types failed" , __func__);
19- return false ;
20- }
21-
22- if (!checkInputOperandType (0 , (int32_t )OperandType::TENSOR_FLOAT32 ) &&
23- !checkInputOperandType (0 , (int32_t )OperandType::TENSOR_QUANT8_ASYMM )) {
24- return false ;
25- }
26-
2715 const auto & inputDimensionsSize = getInputOperandDimensions (0 ).size ();
2816 if (inputDimensionsSize != 4 ) {
2917 ALOGE (" %s Invalid dimensions size for input(%lu)" , __func__, inputDimensionsSize);
@@ -73,45 +61,46 @@ std::shared_ptr<ngraph::Node> ResizeNearestNeighbor::createNode() {
7361 }
7462
7563 if (!useNchw) inputNode = transpose (NHWC_NCHW , inputNode);
76- // FLOAT16 type check added for future when VPUX plugin support is added
77- if (checkInputOperandType (1 , (int32_t )OperandType::FLOAT32 ) ||
78- checkInputOperandType (1 , (int32_t )OperandType::FLOAT16 )) {
64+
65+ attrs.shape_calculation_mode = ngraph::op::v4::Interpolate::ShapeCalcMode::sizes;
66+ // mode is passed as "nearest" for Nearest Neighbor interpolation
67+ attrs.mode = ngraph::op::v4::Interpolate::InterpolateMode::nearest;
68+ attrs.nearest_mode = ngraph::op::v4::Interpolate::NearestMode::floor;
69+
70+ if (checkInputOperandType (1 , (int32_t )OperandType::FLOAT32 )) {
7971 // In tensorflow lite, resizing by size is supported. Scaling factors are
8072 // calculated based on output shape.
81- attrs.shape_calculation_mode = ngraph::op::v4::Interpolate::ShapeCalcMode::sizes;
8273 width_scale = sModelInfo ->ParseOperationInput <float >(mNnapiOperationIndex , 1 );
8374 height_scale = sModelInfo ->ParseOperationInput <float >(mNnapiOperationIndex , 2 );
8475 out_width = (int )(input_width * width_scale);
8576 out_height = (int )(input_height * height_scale);
86- // Recalculating scaling factors here because of typecasting output shape to
87- // integer
88- width_scale = (float )out_width / (float )input_width;
89- height_scale = (float )out_height / (float )input_height;
77+ } else if (checkInputOperandType (1 , (int32_t )OperandType::FLOAT16 )) {
78+ width_scale = sModelInfo ->ParseOperationInput <_Float16>(mNnapiOperationIndex , 1 );
79+ height_scale = sModelInfo ->ParseOperationInput <_Float16>(mNnapiOperationIndex , 2 );
80+ out_width = (int )(input_width * width_scale);
81+ out_height = (int )(input_height * height_scale);
9082 } else if (checkInputOperandType (1 , (int32_t )OperandType::INT32 )) {
91- attrs.shape_calculation_mode = ngraph::op::v4::Interpolate::ShapeCalcMode::sizes;
9283 out_width = sModelInfo ->ParseOperationInput <int >(mNnapiOperationIndex , 1 );
9384 out_height = sModelInfo ->ParseOperationInput <int >(mNnapiOperationIndex , 2 );
94- width_scale = (float )out_width / (float )input_width;
95- height_scale = (float )out_height / (float )input_height;
9685 }
86+ width_scale = (float )out_width / (float )input_width;
87+ height_scale = (float )out_height / (float )input_height;
9788
9889 if (align_corners == true ) {
9990 attrs.coordinate_transformation_mode =
10091 ngraph::op::v4::Interpolate::CoordinateTransformMode::align_corners;
92+ attrs.nearest_mode = ngraph::op::v4::Interpolate::NearestMode::round_prefer_ceil;
10193 } else if (half_pixel == true ) {
10294 attrs.coordinate_transformation_mode =
10395 ngraph::op::v4::Interpolate::CoordinateTransformMode::half_pixel;
96+ attrs.nearest_mode = ngraph::op::v4::Interpolate::NearestMode::round_prefer_ceil;
10497 } else {
10598 // If none of the align_corners and half_pixel are true, transformation
10699 // mode is set to asymmetric
107100 attrs.coordinate_transformation_mode =
108101 ngraph::op::v4::Interpolate::CoordinateTransformMode::asymmetric;
109102 }
110103
111- // mode is passed as "nearest" for Nearest Neighbor interpolation
112- attrs.mode = ngraph::op::v4::Interpolate::InterpolateMode::nearest;
113- attrs.nearest_mode = ngraph::op::v4::Interpolate::NearestMode::floor;
114-
115104 std::vector<int32_t > output_shape = {out_height, out_width};
116105 auto outputShapeNode = createConstNode (ngraph::element::i32 , {2 }, output_shape);
117106
0 commit comments