Skip to content

Commit 311766b

Browse files
Improved waring when retracing too often
1 parent fd78a7a commit 311766b

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/python/freeze.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,14 +1483,18 @@ nb::object FunctionRecording::record(nb::callable func,
14831483
JitBackend backend = in_variables.backend;
14841484

14851485
frozen_func->recording_counter++;
1486-
if (frozen_func->recording_counter > frozen_func->warn_recording_count)
1486+
if (frozen_func->recording_counter > frozen_func->warn_recording_count &&
1487+
frozen_func->recordings.size() >= 1) {
14871488
jit_log(
14881489
LogLevel::Warn,
14891490
"The frozen function has been recorded %u times, this indicates a "
14901491
"problem with how the frozen function is being called. For "
1491-
"example, calling it with changing python values such as a "
1492-
"index.",
1492+
"example, calling it with changing python values such as an "
1493+
"index. For more information about which variables changed set the "
1494+
"log level to ``LogLevel::Debug``.",
14931495
frozen_func->recording_counter);
1496+
log_diff(LogLevel::Debug, in_variables, *frozen_func->prev_key);
1497+
}
14941498

14951499
jit_log(LogLevel::Info,
14961500
"Recording (n_inputs=%u):", in_variables.variables.size());
@@ -1789,16 +1793,6 @@ nb::object FrozenFunction::operator()(nb::args args, nb::kwargs kwargs) {
17891793
}
17901794

17911795
if (it == this->recordings.end()) {
1792-
#ifndef NDEBUG
1793-
if (this->recordings.size() >= 1)
1794-
log_diff(LogLevel::Debug, *in_variables, *prev_key);
1795-
#else
1796-
if (this->recordings.size() >= 1 &&
1797-
recording_counter + 1 > warn_recording_count) {
1798-
log_diff(LogLevel::Warn, *in_variables, *prev_key);
1799-
}
1800-
#endif
1801-
18021796
{
18031797
// TODO: single traverse
18041798
ADScopeContext ad_scope(drjit::ADScope::Resume, 0, nullptr, 0,

0 commit comments

Comments
 (0)