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 2020/04/05 21:39:58 UTC

[GitHub] [incubator-tvm] icemelon9 opened a new pull request #5241: [Relay][OP] Add fast_erf implementation

icemelon9 opened a new pull request #5241: [Relay][OP] Add fast_erf implementation
URL: https://github.com/apache/incubator-tvm/pull/5241
 
 
   Thanks for contributing to TVM!   Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @ them in the pull request thread.
   
   @anijain2305 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] anijain2305 commented on issue #5241: [Relay][OP] Add fast_erf implementation

Posted by GitBox <gi...@apache.org>.
anijain2305 commented on issue #5241: [Relay][OP] Add fast_erf implementation
URL: https://github.com/apache/incubator-tvm/pull/5241#issuecomment-609598805
 
 
   Do you know why windows build is failing?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] anijain2305 commented on issue #5241: [Relay][OP] Add fast_erf implementation

Posted by GitBox <gi...@apache.org>.
anijain2305 commented on issue #5241: [Relay][OP] Add fast_erf implementation
URL: https://github.com/apache/incubator-tvm/pull/5241#issuecomment-610566829
 
 
   Thanks @icemelon9 @tqchen This is merged

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] icemelon9 commented on a change in pull request #5241: [Relay][OP] Add fast_erf implementation

Posted by GitBox <gi...@apache.org>.
icemelon9 commented on a change in pull request #5241: [Relay][OP] Add fast_erf implementation
URL: https://github.com/apache/incubator-tvm/pull/5241#discussion_r403863239
 
 

 ##########
 File path: topi/include/topi/elemwise.h
 ##########
 @@ -461,5 +462,75 @@ inline Tensor fast_exp(const Tensor& x,
   }
 }
 
+/*!
+ * \brief Fast_tanh_float implementation from Eigen
+ * https://github.com/eigenteam/eigen-git-mirror/blob/master/unsupported/Eigen/src/SpecialFunctions/SpecialFunctionsImpl.h#L290
+ */
+inline Tensor fast_erf_float32(const Tensor& data,
+                               std::string name,
+                               std::string tag) {
+  auto plus_4 = make_const(DataType::Float(32), 4.f);
+  auto minus_4 = make_const(DataType::Float(32), -4.f);
+
+  // The monomial coefficients of the numerator polynomial (odd).
+  auto alpha_1 = make_const(DataType::Float(32), -1.60960333262415e-02f);
+  auto alpha_3 = make_const(DataType::Float(32), -2.95459980854025e-03f);
+  auto alpha_5 = make_const(DataType::Float(32), -7.34990630326855e-04f);
+  auto alpha_7 = make_const(DataType::Float(32), -5.69250639462346e-05f);
+  auto alpha_9 = make_const(DataType::Float(32), -2.10102402082508e-06f);
+  auto alpha_11 = make_const(DataType::Float(32), 2.77068142495902e-08f);
+  auto alpha_13 = make_const(DataType::Float(32), -2.72614225801306e-10f);
+
+  // The monomial coefficients of the denominator polynomial (even).
+  auto beta_0 = make_const(DataType::Float(32), -1.42647390514189e-02f);
+  auto beta_2 = make_const(DataType::Float(32), -7.37332916720468e-03f);
+  auto beta_4 = make_const(DataType::Float(32), -1.68282697438203e-03f);
+  auto beta_6 = make_const(DataType::Float(32), -2.13374055278905e-04f);
+  auto beta_8 = make_const(DataType::Float(32), -1.45660718464996e-05f);
+
+  return compute(data->shape, [&](const Array<Var> &i) {
+      // clamp x
 
 Review comment:
   fixed

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] icemelon9 edited a comment on issue #5241: [Relay][OP] Add fast_erf implementation

Posted by GitBox <gi...@apache.org>.
icemelon9 edited a comment on issue #5241: [Relay][OP] Add fast_erf implementation
URL: https://github.com/apache/incubator-tvm/pull/5241#issuecomment-609601354
 
 
   Not really. The log shows the error
   ```
   2020-04-05T22:36:45.4562113Z D:\a\incubator-tvm\incubator-tvm\topi\src\topi.cc : fatal error C1128: number of sections exceeded object file format limit: compile with /bigobj [D:\a\incubator-tvm\incubator-tvm\build.common\tvm_topi.vcxproj]
   ```
   
   But in TVM cmake, we already set the [`/bigobj`](https://github.com/apache/incubator-tvm/blob/master/CMakeLists.txt#L90) option.
   
   @tqchen Do you have a better idea?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] icemelon9 commented on issue #5241: [Relay][OP] Add fast_erf implementation

Posted by GitBox <gi...@apache.org>.
icemelon9 commented on issue #5241: [Relay][OP] Add fast_erf implementation
URL: https://github.com/apache/incubator-tvm/pull/5241#issuecomment-609601354
 
 
   Not really. The log shows the error
   ```
   2020-04-05T22:36:45.4562113Z D:\a\incubator-tvm\incubator-tvm\topi\src\topi.cc : fatal error C1128: number of sections exceeded object file format limit: compile with /bigobj [D:\a\incubator-tvm\incubator-tvm\build.common\tvm_topi.vcxproj]
   ```
   
   But in TVM cmake, we already set the `/bigobj` option in the [cmake](https://github.com/apache/incubator-tvm/blob/master/CMakeLists.txt#L90).
   
   @tqchen Do you have a better idea?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] tqchen commented on issue #5241: [Relay][OP] Add fast_erf implementation

Posted by GitBox <gi...@apache.org>.
tqchen commented on issue #5241: [Relay][OP] Add fast_erf implementation
URL: https://github.com/apache/incubator-tvm/pull/5241#issuecomment-609835385
 
 
   Let us try to break topi.cc into multiple files grouped by their .h

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] icemelon9 commented on issue #5241: [Relay][OP] Add fast_erf implementation

Posted by GitBox <gi...@apache.org>.
icemelon9 commented on issue #5241: [Relay][OP] Add fast_erf implementation
URL: https://github.com/apache/incubator-tvm/pull/5241#issuecomment-610549195
 
 
   @anijain2305 ci is now green. Could you take a look again?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] anijain2305 commented on a change in pull request #5241: [Relay][OP] Add fast_erf implementation

Posted by GitBox <gi...@apache.org>.
anijain2305 commented on a change in pull request #5241: [Relay][OP] Add fast_erf implementation
URL: https://github.com/apache/incubator-tvm/pull/5241#discussion_r403762862
 
 

 ##########
 File path: topi/include/topi/elemwise.h
 ##########
 @@ -461,5 +462,75 @@ inline Tensor fast_exp(const Tensor& x,
   }
 }
 
+/*!
+ * \brief Fast_tanh_float implementation from Eigen
+ * https://github.com/eigenteam/eigen-git-mirror/blob/master/unsupported/Eigen/src/SpecialFunctions/SpecialFunctionsImpl.h#L290
+ */
+inline Tensor fast_erf_float32(const Tensor& data,
+                               std::string name,
+                               std::string tag) {
+  auto plus_4 = make_const(DataType::Float(32), 4.f);
+  auto minus_4 = make_const(DataType::Float(32), -4.f);
+
+  // The monomial coefficients of the numerator polynomial (odd).
+  auto alpha_1 = make_const(DataType::Float(32), -1.60960333262415e-02f);
+  auto alpha_3 = make_const(DataType::Float(32), -2.95459980854025e-03f);
+  auto alpha_5 = make_const(DataType::Float(32), -7.34990630326855e-04f);
+  auto alpha_7 = make_const(DataType::Float(32), -5.69250639462346e-05f);
+  auto alpha_9 = make_const(DataType::Float(32), -2.10102402082508e-06f);
+  auto alpha_11 = make_const(DataType::Float(32), 2.77068142495902e-08f);
+  auto alpha_13 = make_const(DataType::Float(32), -2.72614225801306e-10f);
+
+  // The monomial coefficients of the denominator polynomial (even).
+  auto beta_0 = make_const(DataType::Float(32), -1.42647390514189e-02f);
+  auto beta_2 = make_const(DataType::Float(32), -7.37332916720468e-03f);
+  auto beta_4 = make_const(DataType::Float(32), -1.68282697438203e-03f);
+  auto beta_6 = make_const(DataType::Float(32), -2.13374055278905e-04f);
+  auto beta_8 = make_const(DataType::Float(32), -1.45660718464996e-05f);
+
+  return compute(data->shape, [&](const Array<Var> &i) {
+      // clamp x
 
 Review comment:
   Should this be 2 spaces instead of 4?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] anijain2305 merged pull request #5241: [Relay][OP] Add fast_erf implementation

Posted by GitBox <gi...@apache.org>.
anijain2305 merged pull request #5241: [Relay][OP] Add fast_erf implementation
URL: https://github.com/apache/incubator-tvm/pull/5241
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services