Visit an attribute node and map to valid MLIR code. This method specifically looks for attributes like method calls, or common attributes we'll see from ubiquitous external modules like `numpy`.
(self, node)
| 2322 | process=process_assignment) |
| 2323 | |
| 2324 | def visit_Attribute(self, node): |
| 2325 | """Visit an attribute node and map to valid MLIR code. |
| 2326 | |
| 2327 | This method |
| 2328 | specifically looks for attributes like method calls, or common |
| 2329 | attributes we'll see from ubiquitous external modules like `numpy`. |
| 2330 | """ |
| 2331 | if isinstance(node.value, |
| 2332 | ast.Name) and not node.value.id in self.symbolTable: |
| 2333 | |
| 2334 | if node.value.id in ['np', 'numpy', 'math']: |
| 2335 | if node.attr == 'complex64': |
| 2336 | self.pushValue(self.getComplexType(width=32)) |
| 2337 | elif node.attr == 'complex128': |
| 2338 | self.pushValue(self.getComplexType(width=64)) |
| 2339 | elif node.attr == 'float64': |
| 2340 | self.pushValue(self.getFloatType(width=64)) |
| 2341 | elif node.attr == 'float32': |
| 2342 | self.pushValue(self.getFloatType(width=32)) |
| 2343 | elif node.attr == 'int64': |
| 2344 | self.pushValue(self.getIntegerType(width=64)) |
| 2345 | elif node.attr == 'int32': |
| 2346 | self.pushValue(self.getIntegerType(width=32)) |
| 2347 | elif node.attr == 'pi': |
| 2348 | self.pushValue(self.getConstantFloat(np.pi)) |
| 2349 | elif node.attr == 'e': |
| 2350 | self.pushValue(self.getConstantFloat(np.e)) |
| 2351 | elif node.attr == 'euler_gamma': |
| 2352 | self.pushValue(self.getConstantFloat(np.euler_gamma)) |
| 2353 | elif node.attr == 'array' or self.__isSupportedNumpyFunction( |
| 2354 | node.attr): |
| 2355 | return |
| 2356 | else: |
| 2357 | self.emitFatalError( |
| 2358 | "{}.{} is not supported".format(node.value.id, |
| 2359 | node.attr), node) |
| 2360 | return |
| 2361 | |
| 2362 | if self.isCudaqName(node.value.id): |
| 2363 | if node.attr in [ |
| 2364 | 'DepolarizationChannel', 'AmplitudeDampingChannel', |
| 2365 | 'PhaseFlipChannel', 'BitFlipChannel', 'PhaseDamping', |
| 2366 | 'ZError', 'XError', 'YError', 'Pauli1', 'Pauli2', |
| 2367 | 'Depolarization1', 'Depolarization2' |
| 2368 | ]: |
| 2369 | self.emitFatalError( |
| 2370 | "noise channels may only be used as part of call expressions", |
| 2371 | node) |
| 2372 | |
| 2373 | # must be handled by the parent |
| 2374 | return |
| 2375 | |
| 2376 | if node.attr == 'ctrl' or node.attr == 'adj': |
| 2377 | # to be processed by the caller |
| 2378 | return |
| 2379 | |
| 2380 | if node.attr == 'copy': |
| 2381 | if self.pushPointerValue: |
nothing calls this directly
no test coverage detected