| 1250 | } |
| 1251 | |
| 1252 | tensorflow::Status ConvertAvgPoolOperator( |
| 1253 | const NodeDef& node, const TensorFlowImportFlags& tf_import_flags, |
| 1254 | const ModelFlags& model_flags, Model* model) { |
| 1255 | CHECK_EQ(node.op(), "AvgPool"); |
| 1256 | TF_QCHECK_OK(CheckInputsCount(node, tf_import_flags, 1)); |
| 1257 | const auto& input_name = node.input(0); |
| 1258 | // We only support NHWC, which is the default data_format. |
| 1259 | // So if data_format is not defined, we're all good. |
| 1260 | if (node.attr().count("data_format")) { |
| 1261 | CHECK_EQ(GetStringAttr(node, "data_format"), "NHWC"); |
| 1262 | } |
| 1263 | CHECK_EQ(GetDataTypeAttr(node, "T"), DT_FLOAT); |
| 1264 | auto* avgpool = new AveragePoolOperator; |
| 1265 | avgpool->inputs.push_back(input_name); |
| 1266 | avgpool->outputs.push_back(node.name()); |
| 1267 | const auto& strides = GetListAttr(node, "strides"); |
| 1268 | CHECK_EQ(strides.i_size(), 4); |
| 1269 | CHECK_EQ(strides.i(0), 1); |
| 1270 | CHECK_EQ(strides.i(3), 1); |
| 1271 | avgpool->stride_height = strides.i(1); |
| 1272 | avgpool->stride_width = strides.i(2); |
| 1273 | const auto& ksize = GetListAttr(node, "ksize"); |
| 1274 | CHECK_EQ(ksize.i_size(), 4); |
| 1275 | CHECK_EQ(ksize.i(0), 1); |
| 1276 | CHECK_EQ(ksize.i(3), 1); |
| 1277 | avgpool->kheight = ksize.i(1); |
| 1278 | avgpool->kwidth = ksize.i(2); |
| 1279 | const auto& padding = GetStringAttr(node, "padding"); |
| 1280 | if (padding == "SAME") { |
| 1281 | avgpool->padding.type = PaddingType::kSame; |
| 1282 | } else if (padding == "VALID") { |
| 1283 | avgpool->padding.type = PaddingType::kValid; |
| 1284 | } else { |
| 1285 | LOG(FATAL) << "Bad padding (only SAME and VALID are supported)"; |
| 1286 | } |
| 1287 | model->operators.emplace_back(avgpool); |
| 1288 | return tensorflow::Status::OK(); |
| 1289 | } |
| 1290 | |
| 1291 | tensorflow::Status ConvertBatchMatMulOperator( |
| 1292 | const NodeDef& node, const TensorFlowImportFlags& tf_import_flags, |
nothing calls this directly
no test coverage detected