MCPcopy Create free account
hub / github.com/pytorch/executorch / get_tensor

Function get_tensor

examples/qualcomm/qaihub_scripts/utils/export.py:113–148  ·  view source on GitHub ↗
(io_info, tensors, logger, checking_output=False)

Source from the content-addressed store, hash-verified

111
112
113def get_tensor(io_info, tensors, logger, checking_output=False):
114 # check if enough tensors have been given
115 if len(tensors) != len(io_info):
116 logger.error(
117 "given tensor numbers mismatch, "
118 f"expected {len(io_info)} but got {len(tensors)}"
119 )
120 if checking_output:
121 logger.error(
122 "output tensors failed to generate, "
123 "please check executor_runner logs."
124 )
125 exit(-1)
126
127 return [get_ones_tensor(t, logger) for t in io_info]
128
129 # list of tensors to be returned
130 ret_tensors = []
131 for i, info in enumerate(io_info):
132 if list(tensors[i].shape) != info["shape"]:
133 logger.error(
134 f"tensor '{info['name']}' shape mismatch: "
135 f"users > {tensors[i].shape} - "
136 f"required > {info['shape']}"
137 )
138 ret_tensors.append(get_ones_tensor(info, logger))
139 continue
140
141 ret_tensors.append(
142 tensors[i]
143 if tensors[i].dtype == eval(info["dtype"])
144 else
145 # try quant / dequant for given tensor if possible
146 ret_tensors.append(get_tensor_with_encoding(tensors[i], info, logger))
147 )
148 return [ret_tensors]
149
150
151def to_context_binary(

Callers 2

executeFunction · 0.70
post_processFunction · 0.70

Calls 3

get_ones_tensorFunction · 0.85
get_tensor_with_encodingFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected