microsoft / microsoft/onnxruntime
would you mind exchange the order of max and min while compute clip
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 21.9k
- Forks
- 4.2k
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 184
Description
**Describe the bug**
it is not a real bug, would you mind exchange the order of max and min while compute clip .while min is greater than max(even this is not a normal scene),onnxruntime has different result with tensorflow.i think it is better to have the same order with other Ai framework.
**System information**
Linux Ubuntu 16.04
ONNX Runtime installed from binary
ONNX Runtime version:1.4.0
Python version:3.5
tensorflow:1.12.0
**tensorflow code**
`with ops.name_scope(name, "clip_by_value",
[t, clip_value_min, clip_value_max]) as name:
t = ops.convert_to_tensor(t, name="t")
# Go through list of tensors, for each value in each tensor clip
t_min = math_ops.minimum(t, clip_value_max)
# Assert that the shape is compatible with the initial shape,
# to prevent unintentional broadcasting.
_ = t.shape.merge_with(t_min.shape)
t_max = math_ops.maximum(t_min, clip_value_min, name=name)
_ = t.shape.merge_with(t_max.shape`
**onnx code**
`template
struct Clip::ComputeImpl {
void operator()(const Tensor* X, const Tensor* min, const Tensor* max, Tensor* Y) const {
auto min_val = std::numeric_limits::lowest();
auto max_val = std::numeric_limits::max();
if (min) {
ORT_ENFORCE(min->Shape().NumDimensions() == 0, "min should be a scalar.");
min_val = *(min->template Data());
}
if (max) {
ORT_ENFORCE(max->Shape().NumDimensions() == 0, "max should be a scalar.");
max_val = *(max->template Data());
}
EigenVectorMap(Y->template MutableData(), Y->Shape().Size()) =
ConstEigenVectorMap(X->template Data(), X->Shape().Size())
.cwiseMax(min_val)
.cwiseMin(max_val);
}
};
`
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Clip::ComputeImpl entry point shown in the issue and compare its clipping order with the TensorFlow example. Verify the behavior when min is greater than max, then confirm the resulting Clip behavior against the expected framework semantics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100