You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/08/06 16:47:30 UTC
[GitHub] [tvm] comaniac commented on a change in pull request #8672: [Contrib] Support fp16 input in cpu sort
comaniac commented on a change in pull request #8672:
URL: https://github.com/apache/tvm/pull/8672#discussion_r684371572
##########
File path: tests/python/relay/test_op_level6.py
##########
@@ -25,15 +25,14 @@
@tvm.testing.uses_gpu
def test_sort():
- def verify_sort(shape, axis, is_ascend, is_dyn=False):
-
+ def verify_sort(shape, axis, is_ascend, is_dyn=False, in_dtype="float32"):
Review comment:
We could also do a small refactoring for this file:
- Use `@pytest.mark.parametrize("in_dtype", ["float32", "float16"])` in each unit test.
- Let pytest collect tests in the main function:
```python
if __name__ == "__main__":
pytest.main([__file__])
```
##########
File path: src/runtime/contrib/sort/sort.cc
##########
@@ -153,27 +174,29 @@ void sort_impl(DLTensor* input, DLTensor* output, int32_t axis, bool is_ascend,
} else {
std::stable_sort(sorter.begin(), sorter.end(), CompareDescend<DataType>);
}
- if (is_argsort) {
- for (int64_t k = 0; k < input->shape[axis]; ++k) {
- out_ptr[base_idx + k * axis_mul_after] = static_cast<OutType>(sorter[k].first);
- }
- } else {
- for (int64_t k = 0; k < input->shape[axis]; ++k) {
- out_ptr[base_idx + k * axis_mul_after] = static_cast<OutType>(sorter[k].second);
- }
+ for (int64_t k = 0; k < input->shape[axis]; ++k) {
+ epilogue(out_ptr, base_idx + k * axis_mul_after, sorter[k]);
Review comment:
Thanks for the explanation. Make sense to me.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org