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

Method InferShape

operator/operator/sparsetodense.cpp:7–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5
6namespace TEngine {
7bool SparseToDense::InferShape(const std::vector<TEngine::TShape>& ishape, std::vector<TEngine::TShape>& oshape, int layout)
8{
9 const TShape& input = ishape[0];
10 const TShape& output_shape = ishape[1];
11 const std::vector<int>& in_dim = input.GetDim();
12 const std::vector<int>& out_dim = output_shape.GetDim();
13 const int output_shape_size0 = param_.output_shape_size0;
14 const int output_shape_size1 = param_.output_shape_size1;
15 std::vector<int> output_shape_dim;
16 output_shape_dim.push_back(output_shape_size0);
17
18 if(( int )in_dim.size() > 2)
19 {
20 return false;
21 }
22
23 TShape shape;
24
25 if((( int )out_dim.size() == 2) & (( int )in_dim.size() == 2) & (output_shape_size1 != 0))
26 {
27 output_shape_dim.push_back(output_shape_size1);
28 shape.SetDim(output_shape_dim);
29 shape.SetDataLayout(input.GetDataLayout());
30 oshape[0] = shape;
31 }
32
33 else if((( int )out_dim.size() == 1) & (( int )in_dim.size() == 1 || ( int )in_dim.size() == 0))
34 {
35 shape.SetDim(output_shape_dim);
36 oshape[0] = shape;
37 shape.SetDataLayout(input.GetDataLayout());
38 }
39
40 else
41 {
42 return false;
43 }
44
45
46 return true;
47}
48void SparseToDense::SetSchema(void)
49{
50 Input({"input:int32", "output_shape:int32", "sparse_values:float32"})

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