Skip to content

Conversation

@dzhwinter
Copy link
Contributor

fix #9416

Copy link
Contributor

@panyx0718 panyx0718 left a comment

Choose a reason for hiding this comment

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

LG overall
It would be great if we have a single source of truth of the in-place activation op list.

Copy link
Contributor

Choose a reason for hiding this comment

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

can this flatten been avoided?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@panyx0718 panyx0718 Apr 8, 2018

Choose a reason for hiding this comment

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

Can we have this in C++
static char* inplace_acts = ["sigmoid", "exp", ...]
bool IsInPlaceAct(const string& n) {
return n in inplace_acts;
}
Inplace() { IsInPlaceAct("exp") }

in Python, we expose IsInPlaceAct() as core._is_in_place_act()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can do that as a follow up, it seems the python style is is_in_place().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function bind c++ and Python, I thought that we should follow the c++ style where it been defined.

return
self.check_grad(['X'], 'Out', max_relative_error=0.007)
# the gradient on floor, ceil, round is undefined.
# we return zero as gradient, but the numpy return nan
Copy link
Contributor

Choose a reason for hiding this comment

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

Something to consider in the future
returning None or Nan might be preferred since it avoids constructing a large zero tensor, saving some time and space.

Just curious, why it works before this PR?

# pybind USE_OP
if (${pybind_flag} EQUAL 0)
# NOTE(*): activation use macro to regist the kernels, set use_op manually.
if(${TARGET} STREQUAL "activation")
Copy link
Contributor

Choose a reason for hiding this comment

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

Hopefully, we can remove this hard-coded "activation" and "relu" strings in the cmake files the future.

Add a TODO to clean up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep. The CMakeLists in operators need a clean up, will file a PR do this later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In-place Operations

3 participants