ITADN

`AttributeError`s in `problem.show()` for certain arithmetic expressions

#38Closeddanieldjohnson 创建于 2024-09-01
D
danieldjohnsoncommented
If you add things in a particular order, you can get this confusing error message when generating the (very cool!) visualization of reads and writes. This seems to be triggered when you add a shared read (tracked as a `Scalar`) to a mathematical expression (tracked as a `ScalarHistory`). Somewhat minimal repro: ```python TPB = 8 def error_repro(cuda): def call(out, a, size) -> None: shared = cuda.shared.array(TPB, numba.float32) i = cuda.blockIdx.x * cuda.blockDim.x + cuda.threadIdx.x local_i = cuda.threadIdx.x val = a[i] * a[i] val += 1.0 shared[local_i] = 0.0 cuda.syncthreads() shared[local_i] = shared[local_i] + val # <- bad line! # shared[local_i] = val + shared[local_i] # <- this works cuda.syncthreads() out[i] = shared[local_i] return call SIZE = 8 out = np.zeros(SIZE) a = np.arange(SIZE) problem = CudaProblem( "Pooling", error_repro, [a], out, [SIZE], threadsperblock=Coord(TPB, 1), blockspergrid=Coord(1, 1), spec=pool_spec, ) problem.show() ``` Traceback: ``` AttributeError Traceback (most recent call last) <ipython-input-169-389d915eeb33> in <cell line: 32>() 30 spec=pool_spec, 31 ) ---> 32 problem.show() 1 frames /content/lib.py in show(self, sparse) 389 def show(self, sparse=False): 390 results = self.run_python() --> 391 self.score(results) 392 return draw_results(results, self.name, 393 self.threadsperblock.x, self.threadsperblock.y, sparse) /content/lib.py in score(self, results) 373 count["shared_writes"] += 1 374 for ins in inc[1].inputs: --> 375 if ins.location[0].startswith("S"): 376 count["shared_reads"] += 1 377 else: AttributeError: 'ScalarHistory' object has no attribute 'location' ```
关闭于 2024-09-01 2 条评论