Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18531
Currently we use C10_LOG_EVERY_MS to log the data type change, but it pollutes the log of some service,
we would like to change it to C10_LOG_FIRST_N to prevent that.
Reviewed By: dzhulgakov
Differential Revision:
D14647704
fbshipit-source-id:
b84e4002bd4aa94d616133cd1049c3d4ab05386e
#define C10_LOG_EVERY_MS(severity, ms) LOG(severity)
#endif
+// Same for LOG_FIRST_N
+#ifdef LOG_FIRST_N
+#define C10_LOG_FIRST_N(severity, n) LOG_FIRST_N(severity, n)
+#else
+#define C10_LOG_FIRST_N(severity, n) LOG(severity)
+#endif
+
namespace c10 {
using std::string;
if (tensor->dtype() == options.dtype()) {
tensor->raw_mutable_data();
} else {
- C10_LOG_EVERY_MS(WARNING, 1000)
+ C10_LOG_FIRST_N(WARNING, 1)
<< "Changing the data type of Tensor is discouraged."
<< " Attempt to change data type from: " << tensor->dtype()
<< " to: " << options.dtype();