You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
graphengine/ge/graph/passes/reshape_remove_pass.cc

47 lines
1.4 KiB

5 years ago
/**
* Copyright 2020 Huawei Technologies Co., Ltd
5 years ago
*
* 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 "graph/passes/reshape_remove_pass.h"
#include "framework/common/util.h"
5 years ago
#include "graph/passes/pass_utils.h"
#include "graph/utils/node_utils.h"
5 years ago
namespace ge {
namespace {
const int kReshapeDataIndex = 0;
}
5 years ago
Status ReshapeRemovePass::Run(NodePtr &node) {
GE_CHECK_NOTNULL(node);
GE_CHECK_NOTNULL(node->GetOpDesc());
if (node->GetType() != RESHAPE && node->GetType() != REFORMAT) {
5 years ago
return SUCCESS;
}
bool is_shape_unknown = false;
if (NodeUtils::GetNodeUnknownShapeStatus(*node, is_shape_unknown) == GRAPH_SUCCESS) {
if (is_shape_unknown) {
4 years ago
GELOGI("op:%s is unknown shape, can not be deleted.",
node->GetName().c_str());
return SUCCESS;
}
5 years ago
}
GELOGI("Remove %s node %s", node->GetType().c_str(), node->GetName().c_str());
5 years ago
return IsolateAndDeleteNode(node, {kReshapeDataIndex});
}
} // namespace ge