[CPU] Interpolate node: 5d support for onnx_linear mode (#3471)
This commit is contained in:
parent
79fa676e35
commit
4570550636
File diff suppressed because it is too large
Load Diff
@ -10,7 +10,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#define MAX_INPUT_INTERPOLATE 4
|
||||
#define MAX_INPUT_INTERPOLATE 8
|
||||
|
||||
using namespace InferenceEngine;
|
||||
|
||||
@ -52,7 +52,8 @@ struct jit_interpolate_config_params {
|
||||
int src_data_size;
|
||||
int dst_data_size;
|
||||
int indices_size;
|
||||
int IH, IW, OH, OW;
|
||||
int spatial_dim_size;
|
||||
int ID, IH, IW, OD, OH, OW;
|
||||
};
|
||||
|
||||
struct jit_interpolate_call_args {
|
||||
@ -104,9 +105,10 @@ private:
|
||||
void NNRef(const uint8_t *in_ptr_, uint8_t *out_ptr_, int B, int C, int ID, int IH, int IW, int OD, int OH, int OW);
|
||||
|
||||
// onnx linear
|
||||
void linearOnnxPlanar(const uint8_t *in_ptr_, uint8_t *out_ptr_, int B, int C, int IH, int IW, int OH, int OW);
|
||||
void linearOnnxCGathered(const uint8_t *in_ptr_, uint8_t *out_ptr_, int B, int C, int IH, int IW, int OH, int OW);
|
||||
void linearOnnxRef(const uint8_t *in_ptr_, uint8_t *out_ptr_, int B, int C, int IH, int IW, int OH, int OW);
|
||||
void linearOnnxCF(int outCoord, float scale, int inShape, int outShape, int& index0, int& index1, float& weight0, float& weight1);
|
||||
void linearOnnxPlanar(const uint8_t *in_ptr_, uint8_t *out_ptr_, int B, int C, int ID, int IH, int IW, int OD, int OH, int OW);
|
||||
void linearOnnxCGathered(const uint8_t *in_ptr_, uint8_t *out_ptr_, int B, int C, int ID, int IH, int IW, int OD, int OH, int OW);
|
||||
void linearOnnxRef(const uint8_t *in_ptr_, uint8_t *out_ptr_, int B, int C, int ID, int IH, int IW, int OD, int OH, int OW);
|
||||
|
||||
// cubic
|
||||
std::vector<float> getCubicCoeffs(float mantissa, float a);
|
||||
@ -158,6 +160,7 @@ private:
|
||||
std::string shapeInferMode;
|
||||
SizeVector srcDim;
|
||||
SizeVector srcDimPad;
|
||||
int spatialDimSize;
|
||||
|
||||
mkldnn::primitive_attr attr;
|
||||
std::vector<MKLDNNMemoryPtr> PostOpsIntBlobMemory;
|
||||
@ -169,7 +172,7 @@ private:
|
||||
|
||||
std::vector<int> indexTable;
|
||||
|
||||
std::shared_ptr<jit_uni_interpolate_kernel> interpolateKernel;
|
||||
std::shared_ptr<jit_uni_interpolate_kernel> interpolateKernel = nullptr;
|
||||
};
|
||||
|
||||
} // namespace MKLDNNPlugin
|
||||
|
@ -20,10 +20,6 @@ const std::vector<std::vector<size_t>> inShapes = {
|
||||
{1, 4, 30, 30},
|
||||
};
|
||||
|
||||
const std::vector<std::vector<size_t>> targetShapes = {
|
||||
{1, 4, 40, 40},
|
||||
};
|
||||
|
||||
const std::vector<ngraph::op::v4::Interpolate::InterpolateMode> modesWithoutNearest = {
|
||||
ngraph::op::v4::Interpolate::InterpolateMode::linear,
|
||||
ngraph::op::v4::Interpolate::InterpolateMode::linear_onnx,
|
||||
@ -78,8 +74,12 @@ const std::vector<std::vector<int64_t>> defaultAxes = {
|
||||
{2, 3}
|
||||
};
|
||||
|
||||
const std::vector<std::vector<size_t>> targetShapes = {
|
||||
{40, 40},
|
||||
};
|
||||
|
||||
const std::vector<std::vector<float>> defaultScales = {
|
||||
{1.33333f, 1.33333f}
|
||||
{1.333333f, 1.333333f}
|
||||
};
|
||||
|
||||
const auto interpolateCasesWithoutNearest = ::testing::Combine(
|
||||
@ -135,7 +135,7 @@ const std::vector<std::vector<size_t>> targetShapesTailTest = {
|
||||
};
|
||||
|
||||
const std::vector<std::vector<float>> defaultScalesTailTest = {
|
||||
{0.33333f, 1.36666f}
|
||||
{0.333333f, 1.366666f}
|
||||
};
|
||||
|
||||
const auto interpolateCasesWithoutNearestTail = ::testing::Combine(
|
||||
|
@ -287,6 +287,97 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Enforced_Bf16_Layout_Test, Interpolate
|
||||
::testing::ValuesIn(filterCPUInfoForDevice())),
|
||||
InterpolateLayerCPUTest::getTestCaseName);
|
||||
|
||||
|
||||
////////////////////////5D/////////////////////////////
|
||||
std::vector<CPUSpecificParams> filterCPUInfoForDevice5D() {
|
||||
std::vector<CPUSpecificParams> resCPUParams;
|
||||
if (with_cpu_x86_avx512f()) {
|
||||
resCPUParams.push_back(CPUSpecificParams{{nCdhw16c, x, x}, {nCdhw16c}, {"jit_avx512"}, "jit_avx512_FP32"});
|
||||
resCPUParams.push_back(CPUSpecificParams{{ndhwc, x, x}, {ndhwc}, {"jit_avx512"}, "jit_avx512_FP32"});
|
||||
resCPUParams.push_back(CPUSpecificParams{{ncdhw, x, x}, {ncdhw}, {"jit_avx512"}, "jit_avx512_FP32"});
|
||||
} else if (with_cpu_x86_avx2()) {
|
||||
resCPUParams.push_back(CPUSpecificParams{{nCdhw8c, x, x}, {nCdhw8c}, {"jit_avx2"}, "jit_avx2_FP32"});
|
||||
resCPUParams.push_back(CPUSpecificParams{{ndhwc, x, x}, {ndhwc}, {"jit_avx2"}, "jit_avx2_FP32"});
|
||||
resCPUParams.push_back(CPUSpecificParams{{ncdhw, x, x}, {ncdhw}, {"jit_avx2"}, "jit_avx2_FP32"});
|
||||
} else if (with_cpu_x86_sse42()) {
|
||||
resCPUParams.push_back(CPUSpecificParams{{nCdhw8c, x, x}, {nCdhw8c}, {"jit_sse42"}, "jit_sse42_FP32"});
|
||||
resCPUParams.push_back(CPUSpecificParams{{ndhwc, x, x}, {ndhwc}, {"jit_sse42"}, "jit_sse42_FP32"});
|
||||
resCPUParams.push_back(CPUSpecificParams{{ncdhw, x, x}, {ncdhw}, {"jit_sse42"}, "jit_sse42_FP32"});
|
||||
} else {
|
||||
resCPUParams.push_back(CPUSpecificParams{{ncdhw, x, x}, {ncdhw}, {"ref"}, "ref_FP32"});
|
||||
}
|
||||
return resCPUParams;
|
||||
}
|
||||
|
||||
const std::vector<std::vector<size_t>> pads5D = {
|
||||
{0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
const std::vector<std::vector<int64_t>> defaultAxes5D = {
|
||||
{2, 3, 4}
|
||||
};
|
||||
|
||||
const std::vector<std::vector<float>> defaultScales5D = {
|
||||
{1.25f, 1.5f, 1.5f}
|
||||
};
|
||||
|
||||
const auto interpolateCasesLinearOnnx5D = ::testing::Combine(
|
||||
::testing::Values(ngraph::op::v4::Interpolate::InterpolateMode::linear_onnx),
|
||||
::testing::ValuesIn(shapeCalculationMode),
|
||||
::testing::ValuesIn(coordinateTransformModes),
|
||||
::testing::ValuesIn(nearestModes),
|
||||
::testing::ValuesIn(antialias),
|
||||
::testing::ValuesIn(pads5D),
|
||||
::testing::ValuesIn(pads5D),
|
||||
::testing::ValuesIn(cubeCoefs),
|
||||
::testing::ValuesIn(defaultAxes5D),
|
||||
::testing::ValuesIn(defaultScales5D));
|
||||
|
||||
const auto interpolateCasesNN5D = ::testing::Combine(
|
||||
::testing::Values(ngraph::op::v4::Interpolate::InterpolateMode::linear_onnx),
|
||||
::testing::ValuesIn(shapeCalculationMode),
|
||||
::testing::ValuesIn(coordinateTransformModes),
|
||||
::testing::ValuesIn(defNearestModes),
|
||||
::testing::ValuesIn(antialias),
|
||||
::testing::ValuesIn(pads5D),
|
||||
::testing::ValuesIn(pads5D),
|
||||
::testing::ValuesIn(cubeCoefs),
|
||||
::testing::ValuesIn(defaultAxes5D),
|
||||
::testing::ValuesIn(defaultScales5D));
|
||||
|
||||
// open when ref merged
|
||||
// INSTANTIATE_TEST_CASE_P(smoke_InterpolateLinearOnnx5D_Layout_Test, InterpolateLayerCPUTest,
|
||||
// ::testing::Combine(
|
||||
// ::testing::Combine(
|
||||
// interpolateCasesLinearOnnx5D,
|
||||
// ::testing::ValuesIn(netPrecisions),
|
||||
// ::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
// ::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
// ::testing::Values(InferenceEngine::Layout::ANY),
|
||||
// ::testing::Values(InferenceEngine::Layout::ANY),
|
||||
// ::testing::Values(std::vector<size_t>({1, 21, 4, 10, 10})),
|
||||
// ::testing::Values(std::vector<size_t>({1, 21, 5, 15, 15})),
|
||||
// ::testing::Values(CommonTestUtils::DEVICE_CPU)),
|
||||
// ::testing::Values(std::map<std::string, std::string> {}),
|
||||
// ::testing::ValuesIn(filterCPUInfoForDevice5D())),
|
||||
// InterpolateLayerCPUTest::getTestCaseName);
|
||||
|
||||
// INSTANTIATE_TEST_CASE_P(smoke_InterpolateNN5D_Layout_Test, InterpolateLayerCPUTest,
|
||||
// ::testing::Combine(
|
||||
// ::testing::Combine(
|
||||
// interpolateCasesNN5D,
|
||||
// ::testing::ValuesIn(netPrecisions),
|
||||
// ::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
// ::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
// ::testing::Values(InferenceEngine::Layout::ANY),
|
||||
// ::testing::Values(InferenceEngine::Layout::ANY),
|
||||
// ::testing::Values(std::vector<size_t>({1, 21, 4, 10, 10})),
|
||||
// ::testing::Values(std::vector<size_t>({1, 21, 5, 15, 15})),
|
||||
// ::testing::Values(CommonTestUtils::DEVICE_CPU)),
|
||||
// ::testing::Values(std::map<std::string, std::string> {}),
|
||||
// ::testing::ValuesIn(filterCPUInfoForDevice5D())),
|
||||
// InterpolateLayerCPUTest::getTestCaseName);
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace CPULayerTestsDefinitions
|
||||
|
@ -185,7 +185,7 @@ void op::v4::Interpolate::infer_using_scales(PartialShape& output_shape,
|
||||
if (padded_input_shape[axis].is_static())
|
||||
{
|
||||
float padded_len = static_cast<float>(padded_input_shape[axis].get_length());
|
||||
int64_t new_dim = static_cast<int64_t>(padded_len * scales[i] + epsilon);
|
||||
int64_t new_dim = static_cast<int64_t>(padded_len * (scales[i] + epsilon));
|
||||
output_shape[axis] = Dimension(new_dim);
|
||||
}
|
||||
++i;
|
||||
|
Loading…
Reference in New Issue
Block a user