-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
RfC: Enforce consistent formatting on CI #1957
base: main
Are you sure you want to change the base?
Conversation
1444d24
to
576fc1f
Compare
This PR is to support the discussion on enforcing consistent formatting on the CI [1]. [1] spcl#1804
576fc1f
to
bc44c5e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this review, I want to highlight a couple places where we could end up putting manual guards to force a particular code layout.
dace/frontend/python/newast.py
Outdated
ind_entry, ind_exit = graph.add_map('indirection', { | ||
'__i%d' % i: '%s:%s+1:%s' % (s, e, t) | ||
for i, (s, e, t) in enumerate(mapped_rng) | ||
}, | ||
debuginfo=pvisitor.current_lineinfo) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an example where we might want to put manual guards around the old version.
dace/frontend/python/replacements.py
Outdated
name, _ = sdfg.add_temp_transient(arr1.shape, restype, arr1.storage) | ||
state.add_mapped_tasklet("_%s_" % opname, {'__i%d' % i: '0:%s' % s | ||
for i, s in enumerate(arr1.shape)}, | ||
{'__in1': Memlet.simple(op1, ','.join(['__i%d' % i for i in range(len(arr1.shape))]))}, | ||
state.add_mapped_tasklet("_%s_" % opname, { | ||
'__i%d' % i: '0:%s' % s | ||
for i, s in enumerate(arr1.shape) | ||
}, {'__in1': Memlet.simple(op1, ','.join(['__i%d' % i for i in range(len(arr1.shape))]))}, | ||
'__out = %s __in1' % opcode, | ||
{'__out': Memlet.simple(name, ','.join(['__i%d' % i for i in range(len(arr1.shape))]))}, | ||
external_edges=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I see: adding mapped tasklets works best if the first argument is already on a new line (at least in the current configuration of yapf)
s[i, j, k] = ( | ||
0.5000 * r[2 * i, 2 * j, 2 * k] + | ||
0.2500 * (r[2 * i - 1, 2 * j, 2 * k] + r[2 * i + 1, 2 * j, 2 * k] + r[2 * i, 2 * j - 1, 2 * k] + | ||
r[2 * i, 2 * j + 1, 2 * k] + r[2 * i, 2 * j, 2 * k - 1] + r[2 * i, 2 * j, 2 * k + 1]) + | ||
0.1250 * (r[2 * i - 1, 2 * j - 1, 2 * k] + r[2 * i - 1, 2 * j + 1, 2 * k] + | ||
r[2 * i + 1, 2 * j - 1, 2 * k] + r[2 * i + 1, 2 * j + 1, 2 * k] + | ||
r[2 * i - 1, 2 * j, 2 * k - 1] + r[2 * i - 1, 2 * j, 2 * k + 1] + | ||
r[2 * i + 1, 2 * j, 2 * k - 1] + r[2 * i + 1, 2 * j, 2 * k + 1] + | ||
r[2 * i, 2 * j - 1, 2 * k - 1] + r[2 * i, 2 * j - 1, 2 * k + 1] + | ||
r[2 * i, 2 * j + 1, 2 * k - 1] + r[2 * i, 2 * j + 1, 2 * k + 1]) + | ||
0.0625 * (r[2 * i - 1, 2 * j - 1, 2 * k - 1] + r[2 * i - 1, 2 * j - 1, 2 * k + 1] + | ||
r[2 * i - 1, 2 * j + 1, 2 * k - 1] + r[2 * i - 1, 2 * j + 1, 2 * k + 1] + | ||
r[2 * i + 1, 2 * j - 1, 2 * k - 1] + r[2 * i + 1, 2 * j - 1, 2 * k + 1] + | ||
r[2 * i + 1, 2 * j + 1, 2 * k - 1] + r[2 * i + 1, 2 * j + 1, 2 * k + 1])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is a perfect example for manual guards
tests/schedule_tree/nesting_test.py
Outdated
assert [type(n) | ||
for n in stree.preorder_traversal()][1:] == [tn.MapScope, tn.MapScope, tn.GeneralLoopScope, | ||
tn.TaskletNode] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that might also warrant a manual guard
tests/sdfg/loop_region_test.py
Outdated
assert stree.as_string() == (f'{tn.INDENTATION}assign i = 0\n' + | ||
f'{tn.INDENTATION}while (i < 10):\n' + | ||
f'{2 * tn.INDENTATION}A[i] = tasklet()\n' + | ||
f'{2 * tn.INDENTATION}assign i = (i + 1)') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More candidates for "assert guards" in this file
bc44c5e
to
4c3bc67
Compare
@romanc I am ok with this PR. Let's discuss it on Thursday to finalize the decision. |
Description
Since there was no pushback on the discussion page1, let's go one step further and start discussing how this could look like in practice.
This PR contains two commits
To see the automated linting infrastructure in action, pull this branch, install the linting extras and run
Most changes you'll see will be whitespace changes. If you don't like the formatting,
yapf
has a couple of knobs we could use for fine-tuning. And there's always the option to manually put guards in select places where auto-formatting isn't good enough.Footnotes
https://github.com/spcl/dace/discussions/1804 ↩