MCPcopy Create free account
hub / github.com/alibaba/MNN / _ROIPooling

Function _ROIPooling

express/NeuralNetWorkOp.cpp:1947–1988  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1945
1946
1947VARP _ROIPooling(VARP input, VARP roi, int pooledHeight, int pooledWidth, float spatialScale, bool outputGrad, VARP backwardDiff) {
1948 if (input == nullptr) {
1949 MNN_ERROR("input nullptr\n");
1950 return nullptr;
1951 }
1952 if (input->getInfo() == nullptr) {
1953 MNN_ERROR("input info nullptr\n");
1954 return nullptr;
1955 }
1956 if (input->getInfo()->order != NC4HW4) {
1957 MNN_ERROR("input format must be nc4hw4\n");
1958 return nullptr;
1959 }
1960 std::unique_ptr<RoiParametersT> roiPooling(new RoiParametersT);
1961 roiPooling->pooledHeight = pooledHeight;
1962 roiPooling->pooledWidth = pooledWidth;
1963 roiPooling->spatialScale = spatialScale;
1964 roiPooling->outputGrad = outputGrad;
1965
1966 std::unique_ptr<OpT> op(new OpT);
1967 op->type = OpType_ROIPooling;
1968 op->main.type = OpParameter_RoiParameters;
1969 op->main.value = roiPooling.release();
1970
1971 if (outputGrad == false) {
1972 return (Variable::create(Expr::create(op.get(), {input, roi})));
1973 }
1974
1975 if (backwardDiff == nullptr) {
1976 MNN_ERROR("backwardDiff is null for roi_pool backward mode\n");
1977 return nullptr;
1978 }
1979 if (backwardDiff->getInfo() == nullptr) {
1980 MNN_ERROR("backwardDiff info nullptr\n");
1981 return nullptr;
1982 }
1983 if (backwardDiff->getInfo()->order != NC4HW4) {
1984 MNN_ERROR("backwardDiff format must be nc4hw4\n");
1985 return nullptr;
1986 }
1987 return (Variable::create(Expr::create(op.get(), {input, roi, backwardDiff})));
1988}
1989
1990VARP _ROIAlign(VARP input, VARP roi, int pooledHeight, int pooledWidth, float spatialScale, int samplingRatio, bool aligned, PoolingMode poolType, bool outputGrad, VARP backwardDiff) {
1991 if (input == nullptr) {

Callers 4

onGradMethod · 0.85
testOnBackendMethod · 0.85
runMethod · 0.85
PyMNNExpr_roi_poolingFunction · 0.85

Calls 4

createFunction · 0.50
getInfoMethod · 0.45
releaseMethod · 0.45
getMethod · 0.45

Tested by 2

testOnBackendMethod · 0.68
runMethod · 0.68