Skip to content

Commit

Permalink
support multiple kernels with the same name, especially in the OOP ca…
Browse files Browse the repository at this point in the history
…ses where multiple member kernels share the same name
  • Loading branch information
yuanming-hu committed Dec 26, 2019
1 parent bc71ec6 commit 609b2a5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion python/taichi/lang/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,12 @@ def message(self):


class Kernel:
counter = 0

def __init__(self, func, is_grad, classkernel=False):
self.func = func
self.kernel_counter = Kernel.counter
Kernel.counter += 1
self.is_grad = is_grad
self.arguments = []
self.argument_names = []
Expand Down Expand Up @@ -172,7 +175,7 @@ def materialize(self, key=None, args=None, arg_features=None):
grad_suffix = ""
if self.is_grad:
grad_suffix = "_grad"
kernel_name = "{}_{}_{}".format(self.func.__name__, key[1], grad_suffix)
kernel_name = "{}_c{}_{}_{}".format(self.func.__name__, self.kernel_counter, key[1], grad_suffix)
import taichi as ti
ti.info("Compiling kernel {}...".format(kernel_name))

Expand Down

0 comments on commit 609b2a5

Please sign in to comment.