forked from alibaba/MNN
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputTf.cpp
More file actions
53 lines (41 loc) · 1.56 KB
/
Copy pathInputTf.cpp
File metadata and controls
53 lines (41 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//
// InputTf.cpp
// MNNConverter
//
// Created by MNN on 2019/01/31.
// Copyright © 2018, Alibaba Group Holding Limited
//
#include "TfUtils.hpp"
#include "tfOpConverter.hpp"
#include "graph.pb.h"
DECLARE_OP_CONVERTER(InputTf);
MNN::OpType InputTf::opType() {
return MNN::OpType_Input;
}
MNN::OpParameter InputTf::type() {
return MNN::OpParameter_Input;
}
void InputTf::run(MNN::OpT *dstOp, TmpNode *srcNode, TmpGraph *tempGraph) {
auto inputParam = new MNN::InputT;
tensorflow::AttrValue value;
if (find_attr_value(srcNode->tfNode, "shape", value)) {
const tensorflow::TensorShapeProto &shape = value.shape();
int64_t dimSize = shape.dim_size();
inputParam->dims.resize(dimSize);
DCHECK(dimSize < 5) << "Placeholder Dim must less than "
"or equal to 4, is "
<< dimSize << " " << srcNode->opName << std::endl;
for (int i = 0; i < dimSize; ++i) {
auto dimValue = shape.dim(i).size();
inputParam->dims[i] = dimValue;
}
}
find_attr_value(srcNode->tfNode, "dtype", value);
inputParam->dtype = (MNN::DataType)value.type();
inputParam->dformat = MNN::MNN_DATA_FORMAT_NHWC;
dstOp->main.value = inputParam;
// Check input output
DCHECK(srcNode->inTensors.size() == 0) << "Placeholder Should Not Have Input: " << srcNode->opName;
DCHECK(srcNode->outTensors.size() >= 1) << "Placeholder Have Not Output: " << srcNode->opName;
}
REGISTER_CONVERTER(InputTf, Placeholder);