Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add benchmark for log_loss op #1327

Merged
merged 4 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions api/dynamic_tests_v2/log_loss.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (c) 2022 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.

from common_import import *


class LogLossConfig(APIConfig):
def __init__(self):
super(LogLossConfig, self).__init__("log_loss")
self.run_torch = False
self.feed_spec = [{"range": [-1, 1]}, {"range": [-1, 1]}]


class PDLogLoss(PaddleDynamicAPIBenchmarkBase):
def build_graph(self, config):
input = self.variable(
name='input', shape=config.input_shape, dtype=config.input_dtype)
label = self.variable(
name='label', shape=config.label_shape, dtype=config.label_dtype)
result = paddle.nn.functional.log_loss(
input=input, label=label, epsilon=config.epsilon)
self.feed_list = [input, label]
self.fetch_list = [result]
if config.backward:
self.append_gradients(result, [input])


if __name__ == '__main__':
test_main(pd_dy_obj=PDLogLoss(), config=LogLossConfig())
39 changes: 39 additions & 0 deletions api/tests_v2/configs/log_loss.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

配置规模太小了,建议扩充到gelu.json的数量级,配置数再增加一个

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改,thx

"op": "log_loss",
"param_info": {
"epsilon": {
"type": "float",
"value": "0.0001"
},
"label": {
"dtype": "float32",
"shape": "[30720L, 1L]",
"type": "Variable"
},
"input": {
"dtype": "float32",
"shape": "[30720L, 1L]",
"type": "Variable"
}
},
"repeat": 10000
}, {
"op": "log_loss",
"param_info": {
"epsilon": {
"type": "float",
"value": "0.001"
},
"label": {
"dtype": "float32",
"shape": "[40960L, 1L]",
"type": "Variable"
},
"input": {
"dtype": "float32",
"shape": "[40960L, 1L]",
"type": "Variable"
}
},
"repeat": 10000
}]