!13309 add functionalize_cond & tf_bidirection_gru_cf_fusion
From: @wangzhe128 Reviewed-by: Signed-off-by:pull/13309/MERGE
commit
bc7db669cb
@ -1,37 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef LITE_MINDSPORE_LITE_TOOLS_CONVERTER_OPS_IF_H_
|
|
||||||
#define LITE_MINDSPORE_LITE_TOOLS_CONVERTER_OPS_IF_H_
|
|
||||||
#include <vector>
|
|
||||||
#include <memory>
|
|
||||||
#include "ops/primitive_c.h"
|
|
||||||
|
|
||||||
using mindspore::ops::PrimitiveC;
|
|
||||||
|
|
||||||
namespace mindspore {
|
|
||||||
namespace lite {
|
|
||||||
constexpr auto kNameIf = "If";
|
|
||||||
class If : public PrimitiveC {
|
|
||||||
public:
|
|
||||||
If() : PrimitiveC(kNameIf) {}
|
|
||||||
~If() = default;
|
|
||||||
MS_DECLARE_PARENT(If, PrimitiveC);
|
|
||||||
};
|
|
||||||
} // namespace lite
|
|
||||||
} // namespace mindspore
|
|
||||||
|
|
||||||
#endif // LITE_MINDSPORE_LITE_TOOLS_CONVERTER_OPS_IF_H_
|
|
@ -1,39 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef LITE_MINDSPORE_LITE_TOOLS_CONVERTER_OPS_LOOP_COND_H_
|
|
||||||
#define LITE_MINDSPORE_LITE_TOOLS_CONVERTER_OPS_LOOP_COND_H_
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <set>
|
|
||||||
#include <cmath>
|
|
||||||
#include "ops/primitive_c.h"
|
|
||||||
|
|
||||||
using mindspore::ops::PrimitiveC;
|
|
||||||
|
|
||||||
namespace mindspore {
|
|
||||||
namespace lite {
|
|
||||||
constexpr auto kNameLoopCond = "LoopCond";
|
|
||||||
class LoopCond : public PrimitiveC {
|
|
||||||
public:
|
|
||||||
LoopCond() : PrimitiveC(kNameLoopCond) {}
|
|
||||||
~LoopCond() = default;
|
|
||||||
MS_DECLARE_PARENT(LoopCond, PrimitiveC);
|
|
||||||
};
|
|
||||||
} // namespace lite
|
|
||||||
} // namespace mindspore
|
|
||||||
|
|
||||||
#endif // LITE_MINDSPORE_LITE_TOOLS_CONVERTER_OPS_LOOP_COND_H_
|
|
@ -0,0 +1,47 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#include "tools/converter/parser/tf/tf_tensor_array_gather_parser.h"
|
||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
#include "tools/converter/parser/tf/tf_node_parser_registry.h"
|
||||||
|
#include "tools/converter/ops/ops_def.h"
|
||||||
|
|
||||||
|
namespace mindspore {
|
||||||
|
namespace lite {
|
||||||
|
ops::PrimitiveC *TFTensorArrayGatherParser::Parse(const tensorflow::NodeDef &tf_op,
|
||||||
|
const std::map<string, const tensorflow::NodeDef *> &tf_node_map,
|
||||||
|
std::vector<std::string> *inputs, int *output_size) {
|
||||||
|
MS_LOG(DEBUG) << "TF TensorArrayGatherParser";
|
||||||
|
if (inputs == nullptr || output_size == nullptr) {
|
||||||
|
MS_LOG(ERROR) << "inputs or output_size is nullptr";
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
auto prim = std::make_unique<TensorArrayGatherV3>();
|
||||||
|
if (prim == nullptr) {
|
||||||
|
MS_LOG(ERROR) << "prim is nullptr";
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
*output_size = 1;
|
||||||
|
for (int i = 0; i < tf_op.input_size(); i++) {
|
||||||
|
inputs->emplace_back(tf_op.input(i));
|
||||||
|
}
|
||||||
|
return prim.release();
|
||||||
|
}
|
||||||
|
TFNodeRegistrar g_tfTensorArrayGatherParser("TensorArrayGatherV3", new TFTensorArrayGatherParser());
|
||||||
|
} // namespace lite
|
||||||
|
} // namespace mindspore
|
@ -0,0 +1,38 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#ifndef MINDSPORE_LITE_TOOLS_CONVERTER_PARSER_TF_TF_TENSOR_ARRAY_GATHER_PARSER_H_
|
||||||
|
#define MINDSPORE_LITE_TOOLS_CONVERTER_PARSER_TF_TF_TENSOR_ARRAY_GATHER_PARSER_H_
|
||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
#include "tools/converter/parser/tf/tf_node_parser.h"
|
||||||
|
|
||||||
|
namespace mindspore {
|
||||||
|
namespace lite {
|
||||||
|
class TFTensorArrayGatherParser : public TFNodeParser {
|
||||||
|
public:
|
||||||
|
TFTensorArrayGatherParser() = default;
|
||||||
|
~TFTensorArrayGatherParser() override = default;
|
||||||
|
|
||||||
|
ops::PrimitiveC *Parse(const tensorflow::NodeDef &tf_op,
|
||||||
|
const std::map<string, const tensorflow::NodeDef *> &tf_node_map,
|
||||||
|
std::vector<std::string> *inputs, int *output_size) override;
|
||||||
|
};
|
||||||
|
} // namespace lite
|
||||||
|
} // namespace mindspore
|
||||||
|
|
||||||
|
#endif // MINDSPORE_LITE_TOOLS_CONVERTER_PARSER_TF_TF_TENSOR_ARRAY_GATHER_PARSER_H_
|
@ -0,0 +1,49 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#include "tools/converter/parser/tf/tf_tensor_array_parser.h"
|
||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
#include "tools/converter/parser/tf/tf_node_parser_registry.h"
|
||||||
|
#include "tools/converter/ops/ops_def.h"
|
||||||
|
|
||||||
|
namespace mindspore {
|
||||||
|
namespace lite {
|
||||||
|
ops::PrimitiveC *TFTensorArrayParser::Parse(const tensorflow::NodeDef &tf_op,
|
||||||
|
const std::map<string, const tensorflow::NodeDef *> &tf_node_map,
|
||||||
|
std::vector<std::string> *inputs, int *output_size) {
|
||||||
|
MS_LOG(DEBUG) << "TF TensorArrayParser";
|
||||||
|
if (inputs == nullptr || output_size == nullptr) {
|
||||||
|
MS_LOG(ERROR) << "inputs or output_size is nullptr";
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
auto prim = std::make_unique<TensorArrayV3>();
|
||||||
|
if (prim == nullptr) {
|
||||||
|
MS_LOG(ERROR) << "prim is nullptr";
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
*output_size = 2;
|
||||||
|
for (int i = 0; i < tf_op.input_size(); i++) {
|
||||||
|
inputs->emplace_back(tf_op.input(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return prim.release();
|
||||||
|
}
|
||||||
|
TFNodeRegistrar g_tfTensorArrayParser("TensorArrayV3", new TFTensorArrayParser());
|
||||||
|
} // namespace lite
|
||||||
|
} // namespace mindspore
|
@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#include "tools/converter/parser/tf/tf_tensor_array_read_parser.h"
|
||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
#include "tools/converter/parser/tf/tf_node_parser_registry.h"
|
||||||
|
#include "tools/converter/ops/ops_def.h"
|
||||||
|
|
||||||
|
namespace mindspore {
|
||||||
|
namespace lite {
|
||||||
|
ops::PrimitiveC *TFTensorArrayReadParser::Parse(const tensorflow::NodeDef &tf_op,
|
||||||
|
const std::map<string, const tensorflow::NodeDef *> &tf_node_map,
|
||||||
|
std::vector<std::string> *inputs, int *output_size) {
|
||||||
|
MS_LOG(DEBUG) << "TF TensorArrayReadParser";
|
||||||
|
if (inputs == nullptr || output_size == nullptr) {
|
||||||
|
MS_LOG(ERROR) << "inputs or output_size is nullptr";
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
auto prim = std::make_unique<TensorArrayReadV3>();
|
||||||
|
if (prim == nullptr) {
|
||||||
|
MS_LOG(ERROR) << "prim is nullptr";
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
*output_size = 1;
|
||||||
|
for (int i = 0; i < tf_op.input_size(); i++) {
|
||||||
|
inputs->emplace_back(tf_op.input(i));
|
||||||
|
}
|
||||||
|
return prim.release();
|
||||||
|
}
|
||||||
|
TFNodeRegistrar g_tfTensorArrayReadParser("TensorArrayReadV3", new TFTensorArrayReadParser());
|
||||||
|
} // namespace lite
|
||||||
|
} // namespace mindspore
|
@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#include "tools/converter/parser/tf/tf_tensor_array_scatter_parser.h"
|
||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
#include "tools/converter/parser/tf/tf_node_parser_registry.h"
|
||||||
|
#include "tools/converter/ops/ops_def.h"
|
||||||
|
|
||||||
|
namespace mindspore {
|
||||||
|
namespace lite {
|
||||||
|
ops::PrimitiveC *TFTensorArrayScatterParser::Parse(const tensorflow::NodeDef &tf_op,
|
||||||
|
const std::map<string, const tensorflow::NodeDef *> &tf_node_map,
|
||||||
|
std::vector<std::string> *inputs, int *output_size) {
|
||||||
|
MS_LOG(DEBUG) << "TF TensorArrayScatterParser";
|
||||||
|
if (inputs == nullptr || output_size == nullptr) {
|
||||||
|
MS_LOG(ERROR) << "inputs or output_size is nullptr";
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
auto prim = std::make_unique<TensorArrayScatterV3>();
|
||||||
|
if (prim == nullptr) {
|
||||||
|
MS_LOG(ERROR) << "prim is nullptr";
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
*output_size = 1;
|
||||||
|
for (int i = 0; i < tf_op.input_size(); i++) {
|
||||||
|
inputs->emplace_back(tf_op.input(i));
|
||||||
|
}
|
||||||
|
return prim.release();
|
||||||
|
}
|
||||||
|
TFNodeRegistrar g_tfTensorArrayScatterParser("TensorArrayScatterV3", new TFTensorArrayScatterParser());
|
||||||
|
} // namespace lite
|
||||||
|
} // namespace mindspore
|
@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#ifndef MINDSPORE_LITE_TOOLS_CONVERTER_PARSER_TF_TF_TENSOR_ARRAY_SCATTER_PARSER_H_
|
||||||
|
#define MINDSPORE_LITE_TOOLS_CONVERTER_PARSER_TF_TF_TENSOR_ARRAY_SCATTER_PARSER_H_
|
||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
#include "tools/converter/parser/tf/tf_node_parser.h"
|
||||||
|
|
||||||
|
namespace mindspore {
|
||||||
|
namespace lite {
|
||||||
|
class TFTensorArrayScatterParser : public TFNodeParser {
|
||||||
|
public:
|
||||||
|
TFTensorArrayScatterParser() = default;
|
||||||
|
~TFTensorArrayScatterParser() override = default;
|
||||||
|
ops::PrimitiveC *Parse(const tensorflow::NodeDef &tf_op,
|
||||||
|
const std::map<string, const tensorflow::NodeDef *> &tf_node_map,
|
||||||
|
std::vector<std::string> *inputs, int *output_size) override;
|
||||||
|
};
|
||||||
|
} // namespace lite
|
||||||
|
} // namespace mindspore
|
||||||
|
|
||||||
|
#endif // MINDSPORE_LITE_TOOLS_CONVERTER_PARSER_TF_TF_TENSOR_ARRAY_SCATTER_PARSER_H_
|
@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#include "tools/converter/parser/tf/tf_tensor_array_size_parser.h"
|
||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
#include "tools/converter/parser/tf/tf_node_parser_registry.h"
|
||||||
|
#include "tools/converter/ops/ops_def.h"
|
||||||
|
|
||||||
|
namespace mindspore {
|
||||||
|
namespace lite {
|
||||||
|
ops::PrimitiveC *TFTensorArraySizeParser::Parse(const tensorflow::NodeDef &tf_op,
|
||||||
|
const std::map<string, const tensorflow::NodeDef *> &tf_node_map,
|
||||||
|
std::vector<std::string> *inputs, int *output_size) {
|
||||||
|
MS_LOG(DEBUG) << "TF TensorArraySizeParser";
|
||||||
|
if (inputs == nullptr || output_size == nullptr) {
|
||||||
|
MS_LOG(ERROR) << "inputs or output_size is nullptr";
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
auto prim = std::make_unique<TensorArraySizeV3>();
|
||||||
|
if (prim == nullptr) {
|
||||||
|
MS_LOG(ERROR) << "prim is nullptr";
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
*output_size = 1;
|
||||||
|
for (int i = 0; i < tf_op.input_size(); i++) {
|
||||||
|
inputs->emplace_back(tf_op.input(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return prim.release();
|
||||||
|
}
|
||||||
|
TFNodeRegistrar g_tfTensorArraySizeParser("TensorArraySizeV3", new TFTensorArraySizeParser());
|
||||||
|
} // namespace lite
|
||||||
|
} // namespace mindspore
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue