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

Function _Sort

express/NeuralNetWorkOp.cpp:1832–1845  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1830}
1831
1832VARP _Sort(VARP x, int axis, bool arg, bool descend) {
1833 std::unique_ptr<OpT> op(new OpT);
1834 op->type = OpType_TopKV2;
1835 op->main.type = OpParameter_TopKV2;
1836 auto topk = new TopKV2T;
1837 topk->largest = descend;
1838 op->main.value = topk;
1839 auto posAxis = _Mod(_Scalar(axis), _Rank(x));
1840 auto K = _Slice(_Shape(x), _Unsqueeze(posAxis, {0}), _Unsqueeze(_Scalar<int32_t>(1), {0}));
1841
1842 std::vector<VARP> inputs {x, K, _Scalar(axis)};
1843 auto expr = Expr::create(op.get(), inputs, 2);
1844 return Variable::create(expr, arg);
1845}
1846
1847VARP _Raster(const std::vector<VARP>& vars, const std::vector<int>& region, const std::vector<int>& shape) {
1848 auto expr = Utils::makeRaster(vars, region, shape, halide_type_of<float>(), MNN_DATA_FORMAT_UNKNOWN);

Callers 3

runMethod · 0.85
_testFromIssueFunction · 0.85
PyMNNExpr_sortFunction · 0.85

Calls 8

_ModFunction · 0.85
_RankFunction · 0.85
_SliceFunction · 0.85
_ShapeFunction · 0.85
_UnsqueezeFunction · 0.85
_ScalarFunction · 0.70
createFunction · 0.50
getMethod · 0.45

Tested by 2

runMethod · 0.68
_testFromIssueFunction · 0.68