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

Method InferShape

operator/operator/expanddims.cpp:29–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27namespace TEngine {
28
29bool ExpandDims::InferShape(const std::vector<TEngine::TShape>& ishape, std::vector<TEngine::TShape>& oshape, int layout)
30{
31 const TShape& input = ishape[0];
32
33 const std::vector<int>& in_dim = input.GetDim();
34 std::vector<int> out_dim;
35 int in_size = in_dim.size();
36 for(int i = 0; i < in_size; i++){
37 out_dim.push_back(in_dim[i]);
38 }
39 out_dim.push_back(0);
40
41 int out_size = in_size + 1;
42 for(int i = 0; i < out_size; i++){
43 if( i < param_.axis){
44 out_dim = in_dim;
45 } else if(i == param_.axis){
46 out_dim[i] = 1;
47 } else {
48 out_dim[i] = in_dim[i-1];
49 }
50 }
51
52 TShape shape;
53 shape.SetDim(out_dim);
54 shape.SetDataLayout(input.GetDataLayout());
55 oshape[0] = shape;
56
57 return true;
58}
59
60void ExpandDims::SetSchema(void)
61{

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