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

Method Pack

exir/_serialize/generated/executorch_flatbuffer/Tensor.py:318–355  ·  view source on GitHub ↗
(self, builder)

Source from the content-addressed store, hash-verified

316
317 # TensorT
318 def Pack(self, builder):
319 if self.sizes is not None:
320 if np is not None and type(self.sizes) is np.ndarray:
321 sizes = builder.CreateNumpyVector(self.sizes)
322 else:
323 TensorStartSizesVector(builder, len(self.sizes))
324 for i in reversed(range(len(self.sizes))):
325 builder.PrependInt32(self.sizes[i])
326 sizes = builder.EndVector()
327 if self.dimOrder is not None:
328 if np is not None and type(self.dimOrder) is np.ndarray:
329 dimOrder = builder.CreateNumpyVector(self.dimOrder)
330 else:
331 TensorStartDimOrderVector(builder, len(self.dimOrder))
332 for i in reversed(range(len(self.dimOrder))):
333 builder.PrependUint8(self.dimOrder[i])
334 dimOrder = builder.EndVector()
335 if self.allocationInfo is not None:
336 allocationInfo = self.allocationInfo.Pack(builder)
337 if self.extraTensorInfo is not None:
338 extraTensorInfo = self.extraTensorInfo.Pack(builder)
339 TensorStart(builder)
340 TensorAddScalarType(builder, self.scalarType)
341 TensorAddStorageOffset(builder, self.storageOffset)
342 if self.sizes is not None:
343 TensorAddSizes(builder, sizes)
344 if self.dimOrder is not None:
345 TensorAddDimOrder(builder, dimOrder)
346 TensorAddRequiresGrad(builder, self.requiresGrad)
347 TensorAddDataBufferIdx(builder, self.dataBufferIdx)
348 if self.allocationInfo is not None:
349 TensorAddAllocationInfo(builder, allocationInfo)
350 TensorAddLayout(builder, self.layout)
351 TensorAddShapeDynamism(builder, self.shapeDynamism)
352 if self.extraTensorInfo is not None:
353 TensorAddExtraTensorInfo(builder, extraTensorInfo)
354 tensor = TensorEnd(builder)
355 return tensor

Callers

nothing calls this directly

Calls 14

TensorStartSizesVectorFunction · 0.85
TensorAddScalarTypeFunction · 0.85
TensorAddStorageOffsetFunction · 0.85
TensorAddSizesFunction · 0.85
TensorAddDimOrderFunction · 0.85
TensorAddRequiresGradFunction · 0.85
TensorAddDataBufferIdxFunction · 0.85
TensorAddAllocationInfoFunction · 0.85
TensorAddLayoutFunction · 0.85
TensorAddShapeDynamismFunction · 0.85
TensorAddExtraTensorInfoFunction · 0.85

Tested by

no test coverage detected