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

Change functions in common.h into template functions (#969) #973

Merged
merged 6 commits into from
Oct 8, 2017
Merged

Change functions in common.h into template functions (#969) #973

merged 6 commits into from
Oct 8, 2017

Conversation

Tony-Y
Copy link
Contributor

@Tony-Y Tony-Y commented Oct 7, 2017

  • CheckElementsIntervalClosed

  • ObtainMinMaxSum

These two functions were changed into template functions.

Tony-Y and others added 3 commits October 7, 2017 17:06
Function names must be in the "Pascal Case" style.

* check_elements_interval_closed to CheckElementsIntervalClosed

* obtain_min_max_sum to ObtainMinMaxSum
* CheckElementsIntervalClosed

* ObtainMinMaxSum

These two functions were changed into template functions.
@@ -604,6 +610,11 @@ inline void ObtainMinMaxSum(const float *w, int nw, float *mi, float *ma, double
if (su != nullptr) *su = sumw;
}

template <typename T>
inline void ObtainMinMaxSum(const T *w, int nw, T *mi, std::nullptr_t, double *su) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

su could be T2 type.
I prefer to remove this function, and using ObtainMinMaxSum<float, double>(w, nw, mi, (float*)nullptr, su) to call the function.

Tony-Y added 2 commits October 8, 2017 13:19
* remove an overload of the function ObtainMinMaxSum
guolinke
guolinke previously approved these changes Oct 8, 2017
for (int i = 0; i < ny; ++i) {
if (y[i] < ymin || y[i] > ymax) {
Log::Fatal("[%s]: does not tolerate element [#%i = %f] outside [%f, %f]", callername, i, y[i], ymin, ymax);
if (typeid(T) == typeid(float) || typeid(T) == typeid(double)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why this ? for the format output ?
you can use the stringstream to format T type.

@guolinke guolinke dismissed their stale review October 8, 2017 05:22

request changes

@guolinke guolinke merged commit 87fa8b5 into microsoft:master Oct 8, 2017
guolinke pushed a commit that referenced this pull request Oct 9, 2017
* Fix coding style (#969)

Function names must be in the "Pascal Case" style.

* check_elements_interval_closed to CheckElementsIntervalClosed

* obtain_min_max_sum to ObtainMinMaxSum

* Change functions in common.h into template functions (#969)

* CheckElementsIntervalClosed

* ObtainMinMaxSum

These two functions were changed into template functions.

* Remove an unpreferable overload

* remove an overload of the function ObtainMinMaxSum

* Use stringstream to format T type
@Tony-Y Tony-Y deleted the fix-coding-style branch October 11, 2017 13:02
@lock lock bot locked as resolved and limited conversation to collaborators Mar 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants