# Default packages
#
-set(FIRMWARE_PACKAGE_VERSION 1468)
+set(FIRMWARE_PACKAGE_VERSION 1474)
set(VPU_CLC_MA2X8X_VERSION "movi-cltools-20.09.2")
#
// StageDataInfo
//
+VPU_DECLARE_ENUM(InterpolateCoordTransMode,
+ HalfPixel = 0,
+ PytorchHalfPixel = 1,
+ Asymmetric = 2,
+ TfHalfPixelForNn = 3,
+ AlignCorners = 4
+)
+VPU_DECLARE_ENUM(InterpolateNearestMode,
+ RoundPreferFloor = 0,
+ RoundPreferCeil = 1,
+ Floor = 2,
+ Ceil = 3,
+ Simple = 4
+)
+
template <typename Val>
class StageDataInfo final {
public:
const std::string& name,
const ie::CNNLayerPtr& layer,
bool antialias,
+ InterpolateCoordTransMode coordinateTransformationMode,
+ InterpolateNearestMode nearestMode,
float factor,
const Data& input,
const Data& output);
if (cmp(interpolateMode, "nearest")) {
// current "Resample" supports the following "Interpolate" modes only:
// coordinate_transformation_mode = half_pixel; nearest_mode = round_prefer_ceil;
+ // coordinate_transformation_mode = asymmetric; nearest_mode = floor;
// other "Interpolate" modes are translated to the default ones
const auto antialias = _layer->GetParamAsBool("antialias", false);
+ const auto coordinateTransformation = _layer->GetParamAsString("coordinate_transformation_mode", "half_pixel");
+ const auto nearest = _layer->GetParamAsString("nearest_mode", "round_prefer_floor");
+ InterpolateCoordTransMode coordinateTransformationMode = InterpolateCoordTransMode::HalfPixel;
+ InterpolateNearestMode nearestMode = InterpolateNearestMode::RoundPreferCeil;
+
+ if (cmp(coordinateTransformation, "asymmetric")) {
+ coordinateTransformationMode = InterpolateCoordTransMode::Asymmetric;
+ }
+
+ if (cmp(nearest, "round_prefer_floor")) {
+ nearestMode = InterpolateNearestMode::RoundPreferFloor;
+ } else if (cmp(nearest, "round_prefer_ceil")) {
+ nearestMode = InterpolateNearestMode::RoundPreferCeil;
+ } else if (cmp(nearest, "floor")) {
+ nearestMode = InterpolateNearestMode::Floor;
+ }
_stageBuilder->addResampleNearestStage(model,
_layer->name,
_layer,
antialias,
+ coordinateTransformationMode,
+ nearestMode,
-1.0f,
input,
output);
} else if (cmp(interpolateMode, "linear")) {
// current "Interp" supports modes "align_corners" and "asymmetric" only
// other "Interpolate" modes are translated to the default ones
- const auto coordinate_transformation_mode = _layer->GetParamAsString("coordinate_transformation_mode", "half_pixel");
+ const auto coordinateTransformationMode = _layer->GetParamAsString("coordinate_transformation_mode", "half_pixel");
_stageBuilder->addInterpStage(model,
_layer->name,
_layer,
- cmp(coordinate_transformation_mode, "align_corners"),
+ cmp(coordinateTransformationMode, "align_corners"),
input,
output);
} else {
auto antialias = attrs().get<bool>("antialias");
auto factor = attrs().get<float>("factor");
auto sampleType = attrs().get<ResampleType>("type");
+ auto coordinateTransformationMode = attrs().get<InterpolateCoordTransMode>("coordinate_transformation_mode");
+ auto nearestMode = attrs().get<InterpolateNearestMode>("nearest_mode");
serializer.append(static_cast<int32_t>(antialias));
serializer.append(static_cast<float>(factor));
serializer.append(static_cast<uint32_t>(sampleType));
+ serializer.append(static_cast<uint32_t>(coordinateTransformationMode));
+ serializer.append(static_cast<uint32_t>(nearestMode));
}
void serializeDataImpl(BlobSerializer& serializer) const override {
const std::string& name,
const ie::CNNLayerPtr& layer,
bool antialias,
+ InterpolateCoordTransMode coordinateTransformationMode,
+ InterpolateNearestMode nearestMode,
float factor,
const Data& input,
const Data& output) {
auto stage = model->addNewStage<ResampleStage>(layer->name, StageType::Resample, layer, {input}, {output});
stage->attrs().set<bool>("antialias", antialias);
+ stage->attrs().set<InterpolateCoordTransMode>("coordinate_transformation_mode", coordinateTransformationMode);
+ stage->attrs().set<InterpolateNearestMode>("nearest_mode", nearestMode);
stage->attrs().set<float>("factor", factor);
stage->attrs().set<ResampleType>("type", ResampleType::Nearest);
ie::details::CaselessEq<std::string> cmp;
const auto method = layer->GetParamAsString("type", "caffe.ResampleParameter.NEAREST");
+ const auto coord = layer->GetParamAsString("coordinate_transformation_mode", "half_pixel");
+ const auto nearest = layer->GetParamAsString("nearest_mode", "round_prefer_ceil");
+ InterpolateCoordTransMode coordinateTransformationMode = InterpolateCoordTransMode::HalfPixel;
+ InterpolateNearestMode nearestMode = InterpolateNearestMode::RoundPreferCeil;
+
+ if (cmp(coord, "asymmetric")) {
+ coordinateTransformationMode = InterpolateCoordTransMode::Asymmetric;
+ }
+ if (cmp(nearest, "floor")) {
+ nearestMode = InterpolateNearestMode::Floor;
+ }
+
if (cmp(method, "caffe.ResampleParameter.NEAREST")) {
_stageBuilder->addResampleNearestStage(model,
layer->name,
layer,
layer->GetParamAsInt("antialias", 0),
+ coordinateTransformationMode, nearestMode,
layer->GetParamAsFloat("factor", -1),
inputs[0],
outputs[0]);
const std::vector<std::vector<size_t>> inShapes = {
{1, 8, 38, 38},
+ {1, 8, 36, 36},
+ {1, 8, 35, 35},
};
const std::vector<std::vector<size_t>> targetShapes = {
{1, 8, 38 * 2, 38 * 2},
+ {1, 8, 70, 70}, // * 1.94
+ {1, 8, 46, 46}, // * 1.3
};
const std::vector<ngraph::op::v4::Interpolate::InterpolateMode> modesWithoutNearest = {
ngraph::op::v4::Interpolate::CoordinateTransformMode::half_pixel,
};
+const std::vector<ngraph::op::v4::Interpolate::CoordinateTransformMode> coordinateTransformModesNearestMore = {
+ ngraph::op::v4::Interpolate::CoordinateTransformMode::asymmetric,
+};
+
const std::vector<ngraph::op::v4::Interpolate::CoordinateTransformMode> coordinateTransformModesWithoutNearest = {
ngraph::op::v4::Interpolate::CoordinateTransformMode::asymmetric,
ngraph::op::v4::Interpolate::CoordinateTransformMode::align_corners,
ngraph::op::v4::Interpolate::NearestMode::round_prefer_ceil,
};
+const std::vector<ngraph::op::v4::Interpolate::NearestMode> defaultNearestModeMore = {
+ ngraph::op::v4::Interpolate::NearestMode::floor,
+};
+
const std::vector<std::vector<size_t>> pads = {
{0, 0, 0, 0},
};
::testing::ValuesIn(defaultAxes),
::testing::ValuesIn(defaultScales));
+const auto interpolateCasesNearestModeMore = ::testing::Combine(
+ ::testing::ValuesIn(nearestMode),
+ ::testing::ValuesIn(shapeCalculationMode),
+ ::testing::ValuesIn(coordinateTransformModesNearestMore),
+ ::testing::ValuesIn(defaultNearestModeMore),
+ ::testing::ValuesIn(antialias),
+ ::testing::ValuesIn(pads),
+ ::testing::ValuesIn(pads),
+ ::testing::ValuesIn(cubeCoefs),
+ ::testing::ValuesIn(defaultAxes),
+ ::testing::ValuesIn(defaultScales));
+
const auto interpolateCasesWithoutNearestMode = ::testing::Combine(
::testing::ValuesIn(modesWithoutNearest),
::testing::ValuesIn(shapeCalculationMode),
::testing::Values(CommonTestUtils::DEVICE_MYRIAD)),
InterpolateLayerTest::getTestCaseName);
+INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode_more, InterpolateLayerTest, ::testing::Combine(
+ interpolateCasesNearestModeMore,
+ ::testing::ValuesIn(netPrecisions),
+ ::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
+ ::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
+ ::testing::Values(InferenceEngine::Layout::ANY),
+ ::testing::Values(InferenceEngine::Layout::ANY),
+ ::testing::ValuesIn(inShapes),
+ ::testing::ValuesIn(targetShapes),
+ ::testing::Values(CommonTestUtils::DEVICE_MYRIAD)),
+ InterpolateLayerTest::getTestCaseName);
+
INSTANTIATE_TEST_CASE_P(smoke_Interpolate_without_nearest, InterpolateLayerTest, ::testing::Combine(
interpolateCasesWithoutNearestMode,
::testing::ValuesIn(netPrecisions),