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

[MXNET-100] Support float16 in Correlation operator #10125

Merged
merged 1 commit into from
Mar 16, 2018

Conversation

haojin2
Copy link
Contributor

@haojin2 haojin2 commented Mar 15, 2018

Description

Add support for any datatype for Correlation operator, which is not mentioned in issue #2302.

Checklist

Essentials

  • Passed code style checking (make lint)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Code is well-documented:
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Change Correlation operator from only supporting real_t to supporting any datatype
  • Add additional test cases for float16

@haojin2 haojin2 force-pushed the fp16_correlation branch 3 times, most recently from 3ad1bdd to 250d5eb Compare March 15, 2018 22:59
Tensor<xpu, 4, DType> tmp1 = out_data[Correlation::kTemp1].get<xpu, 4, DType>(s);
Tensor<xpu, 4, DType> tmp2 = out_data[Correlation::kTemp2].get<xpu, 4, DType>(s);
tmp1 = DType(0.0f);
tmp2 = DType(0.0f);
Copy link
Member

Choose a reason for hiding this comment

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

Preferably, Use static_cast.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, will address this issue shortly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like static_cast is causing some compilation errors, taking a look at it now.

type_assign(&(*out_type)[1], dtype);
type_assign(&(*out_type)[2], dtype);

TYPE_ASSIGN_CHECK(*in_type, 0, dtype);
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need both type_assign and TYPE_ASSIGN_CHECK ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was advice from Jun, he suggested that we can do a mutual inference by reducing all datatypes to one and then assign the reduced type back to everything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the reduced datatype is not -1 then all inputs and outputs will then have the same datatype at the end of this function.

@piiswrong piiswrong merged commit 574f469 into apache:master Mar 16, 2018
@piiswrong
Copy link
Contributor

float16 doesn't work with static_cast

jinhuang415 pushed a commit to jinhuang415/incubator-mxnet that referenced this pull request Mar 30, 2018
rahul003 pushed a commit to rahul003/mxnet that referenced this pull request Jun 4, 2018
zheng-da pushed a commit to zheng-da/incubator-mxnet that referenced this pull request Jun 28, 2018
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.

None yet

3 participants