Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Remove inplace support for ToTensor operator #14083

Merged

Conversation

sandeep-krishnamurthy
Copy link
Contributor

@sandeep-krishnamurthy sandeep-krishnamurthy commented Feb 7, 2019

Description

Remove inplace support for ToTensor operator.

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • Changes are complete (i.e. I finished coding on this PR)
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Comments

@stu1130

@vandanavk
Copy link
Contributor

@mxnet-label-bot add [pr-awaiting-review, Operator]

@marcoabreu marcoabreu added Operator pr-awaiting-review PR is waiting for code review labels Feb 7, 2019
@sandeep-krishnamurthy sandeep-krishnamurthy changed the title Fix to tensor op to be used as part of the model graph Do not use operation request type for ToTensor operator Feb 7, 2019
struct totensor_forward {
template<typename DType>
MSHADOW_XINLINE static void Map(uint32_t c, float* out_data, const DType* in_data,
const int length, const int channel, const int step,
const float normalize_factor = 255.0f) {
#pragma omp parallel for
for (int i = 0; i < length; ++i) {
KERNEL_ASSIGN(out_data[step + c*length + i], req,
(in_data[step + i*channel + c]) / normalize_factor);
out_data[step + c*length + i] =
Copy link
Member

Choose a reason for hiding this comment

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

you should take care of the req rather than disable the check, this is dangerous for any behavior our of your usecase right now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah. You are right. Thanks. I removed the support for in place during operator registration.
Pasting below your notes for any future reference regarding this PR. Thanks.

think about the case from HWC to NCHW
values get overwrite and can never be recovered
to support inplace, you have to have a temp buffer
 .set_attr<nnvm::FInplaceOption>("FInplaceOption",
  [](const NodeAttrs& attrs) {
    return std::vector<std::pair<int, int> >{{0, 0}};
  }) 
disable it
if you don’t want to implement inplace op

@sandeep-krishnamurthy sandeep-krishnamurthy changed the title Do not use operation request type for ToTensor operator Remove stale operation request type check for ToTensor operator Feb 7, 2019
@sandeep-krishnamurthy sandeep-krishnamurthy changed the title Remove stale operation request type check for ToTensor operator Remove unnecessary operation request type check for ToTensor operator Feb 7, 2019
@sandeep-krishnamurthy sandeep-krishnamurthy changed the title Remove unnecessary operation request type check for ToTensor operator Remove inplace support for ToTensor operator Feb 7, 2019
@sandeep-krishnamurthy sandeep-krishnamurthy merged commit 2ff8ce0 into apache:master Feb 8, 2019
stephenrawls pushed a commit to stephenrawls/incubator-mxnet that referenced this pull request Feb 16, 2019
* Remove stale check for op req type

* Do not register to tensor operator with in place option.
vdantu pushed a commit to vdantu/incubator-mxnet that referenced this pull request Mar 31, 2019
* Remove stale check for op req type

* Do not register to tensor operator with in place option.
haohuanw pushed a commit to haohuanw/incubator-mxnet that referenced this pull request Jun 23, 2019
* Remove stale check for op req type

* Do not register to tensor operator with in place option.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Operator pr-awaiting-review PR is waiting for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants