MCPcopy Create free account
hub / github.com/OAID/Tengine / InferShape

Method InferShape

operator/operator/stridedslice.cpp:47–104  ·  view source on GitHub ↗

TShape shape; shape.SetDim(o_dim); shape.SetDataLayout(input.GetDataLayout()); oshape[0] = shape; return true; }

Source from the content-addressed store, hash-verified

45// return true;
46// }
47bool StridedSlice::InferShape(const std::vector<TEngine::TShape>& ishape, std::vector<TEngine::TShape>& oshape,
48 int layout)
49{
50 const TShape& input = ishape[0];
51 const std::vector<int>& in_dim = input.GetDim();
52
53 if(input.GetDim().size() == 4 && param_.shrink_axis_mask == 0)
54
55 {
56 std::vector<int> o_dim = input.GetDim();
57 int delta_0=(-param_.begin[0] + param_.end[0])<0? param_.begin[0] -param_.end[0] :-param_.begin[0] + param_.end[0];
58 int delta_1=(-param_.begin[1] + param_.end[1])<0? param_.begin[1] -param_.end[1] :-param_.begin[1] + param_.end[1];
59 int delta_2=(-param_.begin[2] + param_.end[2])<0? param_.begin[2] -param_.end[2] :-param_.begin[2] + param_.end[2];
60 int delta_3=(-param_.begin[3] + param_.end[3])<0? param_.begin[3] -param_.end[3] :-param_.begin[3] + param_.end[3];
61 o_dim[0]= ceil(((float)in_dim[0]-(float)delta_0)/(float)param_.stride[0]);
62 o_dim[1]= ceil(((float)in_dim[1]-(float)delta_1)/(float)param_.stride[1]);
63 o_dim[2]= ceil(((float)in_dim[2]-(float)delta_2)/(float)param_.stride[2]);
64 o_dim[3]= ceil(((float)in_dim[3]-(float)delta_3)/(float)param_.stride[3]);
65
66
67 TShape shape;
68 shape.SetDim(o_dim);
69 shape.SetDataLayout(input.GetDataLayout());
70 oshape[0] = shape;
71 }
72 else if(input.GetDim().size() == 3 && param_.shrink_axis_mask == 1)
73 {
74 std::vector<int> o_dim(2);
75 o_dim[0] = in_dim[1];
76 o_dim[1] = in_dim[2];
77 TShape shape;
78 shape.SetDim(o_dim);
79 shape.SetDataLayout(input.GetDataLayout());
80 oshape[0] = shape;
81 }
82 else if(input.GetDim().size() == 3 && param_.shrink_axis_mask == 2)
83 {
84 std::vector<int> o_dim(2);
85 o_dim[0] = in_dim[0];
86 o_dim[1] = in_dim[2];
87 TShape shape;
88 shape.SetDim(o_dim);
89 shape.SetDataLayout(input.GetDataLayout());
90 oshape[0] = shape;
91 }
92 else if(input.GetDim().size() == 3 && param_.shrink_axis_mask == 3)
93 {
94 std::vector<int> o_dim(2);
95 o_dim[0] = in_dim[0];
96 o_dim[1] = in_dim[1];
97 TShape shape;
98 shape.SetDim(o_dim);
99 shape.SetDataLayout(input.GetDataLayout());
100 oshape[0] = shape;
101 }
102
103 return true;
104}

Callers

nothing calls this directly

Calls 4

SetDimMethod · 0.80
SetDataLayoutMethod · 0.80
GetDataLayoutMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected