Skip to content

Commit f8515d9

Browse files
committed
added docstrings
Signed-off-by: Sharvari Medhe <smedhe@qti.qualcomm.com>
1 parent e4e4fc4 commit f8515d9

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

QEfficient/generation/cloud_infer.py

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,6 @@
1414

1515
import numpy as np
1616

17-
# try:
18-
# import qaicrt
19-
# except ImportError:
20-
# import platform
21-
# import sys
22-
23-
# sys.path.append(f"/opt/qti-aic/dev/lib/{platform.machine()}")
24-
# import qaicrt
25-
2617

2718
class QAICInferenceSession:
2819
_qaicrt = None
@@ -135,14 +126,25 @@ def output_names(self) -> List[str]:
135126
return [binding.name for binding in self.bindings if binding.dir == self.aicapi.BUFFER_IO_TYPE_OUTPUT]
136127

137128
def activate(self):
129+
"""Activate qpc"""
130+
138131
self.program.activate()
139132
self.execObj = self.qaicrt.ExecObj(self.context, self.program)
140133

141134
def deactivate(self):
135+
"""Deactivate qpc"""
136+
142137
del self.execObj
143138
self.program.deactivate()
144139

145140
def set_buffers(self, buffers: Dict[str, np.ndarray]):
141+
"""
142+
Provide buffer mapping for input and output
143+
144+
Args:
145+
:buffer (Dict[str, np.ndarray]): Parameter for buffer mapping.
146+
"""
147+
146148
for buffer_name, buffer in buffers.items():
147149
if buffer_name not in self.binding_index_map:
148150
warn(f'Buffer: "{buffer_name}" not found')
@@ -155,9 +157,26 @@ def set_buffers(self, buffers: Dict[str, np.ndarray]):
155157
)
156158

157159
def skip_buffers(self, skipped_buffer_names: List[str]):
160+
"""
161+
skip buffer mapping for given list of buffer names
162+
163+
Args:
164+
:skipped_buffer_name: List[str]. List of buffer name to be skipped.
165+
"""
166+
158167
self.set_buffers({k: np.array([]) for k in skipped_buffer_names})
159168

160169
def run(self, inputs: Dict[str, np.ndarray]) -> Dict[str, np.ndarray]:
170+
"""
171+
Execute on cloud AI 100
172+
173+
Args:
174+
:inputs (Dict[str, np.ndarray]): Processed numpy inputs for the model.
175+
176+
Return:
177+
:Dict[str, np.ndarray]:
178+
"""
179+
161180
self.set_buffers(inputs)
162181
if self.execObj.setData(self.qbuffers, self.buf_dims) != self.qaicrt.QStatus.QS_SUCCESS:
163182
raise MemoryError("Failed to setData")

0 commit comments

Comments
 (0)