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

Method InferShape

operator/operator/gru.cpp:7–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5namespace TEngine {
6
7bool GRU::InferShape(const std::vector<TShape>& ishape, std::vector<TShape>& oshape, int layout)
8{
9 // input tensors:
10 // 0 --- input: [seq_length, batch_size,input_size]
11 // 1 --- kernel [ (input_size+hidden_size),hidden_state_size]
12 // others: optional
13
14 // output tensor: [output_len,batch_size,hidden_size]
15
16 const TShape input_shape = ishape[0];
17 int batch_size = input_shape.Shape(0);
18 std::vector<int> dims(3);
19 if(param_.mxnet_flag == 1)
20 {
21 batch_size = input_shape.Shape(1);
22 dims[0] = input_shape.Shape(0);
23 dims[1] = batch_size;
24 dims[2] = param_.hidden_size;
25 }
26 else
27 {
28 dims[1] = input_shape.Shape(0);
29 dims[0] = batch_size;
30 dims[2] = param_.hidden_size;
31 }
32
33 oshape[0].SetDim(dims);
34
35 // std::cout<<dims[0]<<","<< dims[1]<<","<<dims[2]<<"\n";
36
37 return true;
38}
39
40void GRU::SetSchema(void)
41{

Callers

nothing calls this directly

Calls 2

ShapeMethod · 0.80
SetDimMethod · 0.80

Tested by

no test coverage detected