parent
0a95223f25
commit
f9120e6886
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "predict/converter/lite_model/op_attr_packer.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace predict {
|
||||
namespace convert {
|
||||
bool AddFoldPacker(const CNodePtr &c_node_ptr, OpDefT *ms_op) {
|
||||
if (c_node_ptr == nullptr || ms_op == nullptr) {
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<AddFoldT> attr(new AddFoldT());
|
||||
MS_EXCEPTION_IF_NULL(attr);
|
||||
ms_op->attr.type = OpT_AddFold;
|
||||
ms_op->attr.value = attr.release();
|
||||
return true;
|
||||
}
|
||||
} // namespace convert
|
||||
} // namespace predict
|
||||
} // namespace mindspore
|
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "predict/converter/lite_model/op_attr_packer.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace predict {
|
||||
namespace convert {
|
||||
bool ArgMaxPacker(const CNodePtr &c_node_ptr, OpDefT *ms_op) {
|
||||
if (c_node_ptr == nullptr || ms_op == nullptr) {
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<ArgMaxT> attr(new ArgMaxT());
|
||||
MS_EXCEPTION_IF_NULL(attr);
|
||||
ms_op->attr.type = OpT_ArgMax;
|
||||
ms_op->attr.value = attr.release();
|
||||
return true;
|
||||
}
|
||||
} // namespace convert
|
||||
} // namespace predict
|
||||
} // namespace mindspore
|
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "predict/converter/lite_model/op_attr_packer.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace predict {
|
||||
namespace convert {
|
||||
bool BatchNormFoldPacker(const CNodePtr &c_node_ptr, OpDefT *ms_op) {
|
||||
if (c_node_ptr == nullptr || ms_op == nullptr) {
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<BatchNormFoldT> attr(new BatchNormFoldT());
|
||||
MS_EXCEPTION_IF_NULL(attr);
|
||||
ms_op->attr.type = OpT_BatchNormFold;
|
||||
ms_op->attr.value = attr.release();
|
||||
return true;
|
||||
}
|
||||
} // namespace convert
|
||||
} // namespace predict
|
||||
} // namespace mindspore
|
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "predict/converter/lite_model/op_attr_packer.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace predict {
|
||||
namespace convert {
|
||||
bool FakeQuantWithMinMaxPacker(const CNodePtr &c_node_ptr, OpDefT *ms_op) {
|
||||
if (c_node_ptr == nullptr || ms_op == nullptr) {
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<FakeQuantWithMinMaxT> attr(new FakeQuantWithMinMaxT());
|
||||
MS_EXCEPTION_IF_NULL(attr);
|
||||
ms_op->attr.type = OpT_FakeQuantWithMinMax;
|
||||
ms_op->attr.value = attr.release();
|
||||
return true;
|
||||
}
|
||||
} // namespace convert
|
||||
} // namespace predict
|
||||
} // namespace mindspore
|
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "predict/converter/lite_model/op_attr_packer.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace predict {
|
||||
namespace convert {
|
||||
bool FakeQuantWithMinMaxPerChannelPacker(const CNodePtr &c_node_ptr, OpDefT *ms_op) {
|
||||
if (c_node_ptr == nullptr || ms_op == nullptr) {
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<FakeQuantWithMinMaxPerChannelT> attr(new FakeQuantWithMinMaxPerChannelT());
|
||||
MS_EXCEPTION_IF_NULL(attr);
|
||||
ms_op->attr.type = OpT_FakeQuantWithMinMaxPerChannel;
|
||||
ms_op->attr.value = attr.release();
|
||||
return true;
|
||||
}
|
||||
} // namespace convert
|
||||
} // namespace predict
|
||||
} // namespace mindspore
|
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "predict/converter/lite_model/op_attr_packer.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace predict {
|
||||
namespace convert {
|
||||
bool MulPacker(const CNodePtr &c_node_ptr, OpDefT *ms_op) {
|
||||
if (c_node_ptr == nullptr || ms_op == nullptr) {
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<MulT> attr(new MulT());
|
||||
MS_EXCEPTION_IF_NULL(attr);
|
||||
ms_op->attr.type = OpT_Mul;
|
||||
ms_op->attr.value = attr.release();
|
||||
return true;
|
||||
}
|
||||
} // namespace convert
|
||||
} // namespace predict
|
||||
} // namespace mindspore
|
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "predict/converter/lite_model/op_attr_packer.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace predict {
|
||||
namespace convert {
|
||||
bool MulFoldPacker(const CNodePtr &c_node_ptr, OpDefT *ms_op) {
|
||||
if (c_node_ptr == nullptr || ms_op == nullptr) {
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<MulFoldT> attr(new MulFoldT());
|
||||
MS_EXCEPTION_IF_NULL(attr);
|
||||
ms_op->name = c_node_ptr->fullname_with_scope();
|
||||
ms_op->attr.type = OpT_MulFold;
|
||||
ms_op->attr.value = attr.release();
|
||||
return true;
|
||||
}
|
||||
} // namespace convert
|
||||
} // namespace predict
|
||||
} // namespace mindspore
|
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "predict/converter/lite_model/op_attr_packer.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace predict {
|
||||
namespace convert {
|
||||
bool SqueezePacker(const CNodePtr &c_node_ptr, OpDefT *ms_op) {
|
||||
if (c_node_ptr == nullptr || ms_op == nullptr) {
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<SqueezeT> attr(new SqueezeT());
|
||||
MS_EXCEPTION_IF_NULL(attr);
|
||||
|
||||
std::vector<int> kernel_axis_value = AnfAlgo::GetNodeAttr<std::vector<int>>(c_node_ptr, "axis");
|
||||
attr->axis = kernel_axis_value;
|
||||
|
||||
ms_op->attr.type = OpT_Squeeze;
|
||||
ms_op->attr.value = attr.release();
|
||||
return true;
|
||||
}
|
||||
} // namespace convert
|
||||
} // namespace predict
|
||||
} // namespace mindspore
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue