Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, shape, dim_names, var_name='layer{index}', type_name='layer{index}_t', precision=None, pragma='partition', **kwargs):
super(ArrayVariable, self).__init__(var_name, type_name, precision, **kwargs)
self.shape = shape
self.dim_names = dim_names
if pragma == 'partition':
self.partition()
elif pragma == 'reshape':
self.reshape()
elif pragma == 'stream':
self.stream()
else:
self.pragma = None
if out_name is None:
out_name = self.outputs[0]
if precision is None:
precision, _ = self.model.config.get_precision(self, var='result')
if pragma == 'auto':
if self.model.config.get_config_value('IOType') == 'io_serial':
pragma = 'stream'
else:
if self.name in self.model.inputs:
pragma = 'reshape'
else:
pragma = 'partition'
out = ArrayVariable(shape, dim_names, var_name=var_name, type_name=type_name, precision=precision, pragma=pragma, index=self.index)
self.variables[out_name] = out
self.model.register_output_variable(out_name, out)
self.precision[out.type.name] = out.type