-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support op hardtanh & fix unfold empyt
- Loading branch information
1 parent
1e29c15
commit ebea7b9
Showing
14 changed files
with
437 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved. | ||
// | ||
// 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 "paddle2onnx/mapper/activation/hardtanh.h" | ||
|
||
namespace paddle2onnx { | ||
REGISTER_PIR_MAPPER(hardtanh, HardtanhMapper) | ||
|
||
int32_t HardtanhMapper::GetMinOpsetVersion(bool verbose) { | ||
Logger(verbose, 7) << RequireOpset(7) << std::endl; | ||
return 7; | ||
} | ||
|
||
void HardtanhMapper::Opset7() { | ||
auto input_info = GetInput("x"); | ||
auto output_info = GetOutput("out"); | ||
|
||
helper_->Clip( | ||
input_info[0].name, output_info[0].name, min_, max_, input_info[0].dtype); | ||
} | ||
} // namespace paddle2onnx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved. | ||
// | ||
// 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. | ||
#pragma once | ||
|
||
#include <cmath> | ||
#include <map> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "paddle2onnx/mapper/mapper.h" | ||
|
||
namespace paddle2onnx { | ||
class HardtanhMapper : public Mapper { | ||
public: | ||
HardtanhMapper(const PaddlePirParser& p, | ||
OnnxHelper* helper, | ||
int64_t i, | ||
bool c) | ||
: Mapper(p, helper, i, c) { | ||
if (HasAttr("min")) { | ||
GetAttr("min", &min_); | ||
} | ||
if (HasAttr("max")) { | ||
GetAttr("max", &max_); | ||
} | ||
} | ||
|
||
int32_t GetMinOpsetVersion(bool verbose) override; | ||
void Opset7() override; | ||
|
||
private: | ||
float min_ = -1.0; | ||
float max_ = 1.0; | ||
}; | ||
} // namespace paddle2onnx |
Oops, something went wrong.