forked from MPolaris/onnx2tflite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request MPolaris#12 from MPolaris/dev
dev merge request
- Loading branch information
Showing
9 changed files
with
67 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
''' | ||
shape and axis transform utils func. | ||
''' | ||
def channel_to_last_dimension(axis): | ||
''' | ||
make channel first to channel last | ||
''' | ||
if axis == 0: | ||
axis = 0 | ||
elif axis == 1: | ||
axis = -1 | ||
else: | ||
axis -= 1 | ||
return axis | ||
|
||
def shape_NCD_to_NDC_format(shape:list or tuple): | ||
''' | ||
make shape format from channel first to channel last | ||
''' | ||
if len(shape) <= 2: | ||
return tuple(shape) | ||
new_shape = [shape[0], *shape[2:], shape[1]] | ||
return tuple(new_shape) | ||
|
||
def tensor_NCD_to_NDC_format(tensor): | ||
''' | ||
make tensor format from channel first to channel last | ||
''' | ||
if(len(tensor.shape) > 2): | ||
shape = [i for i in range(len(tensor.shape))] | ||
shape = shape_NCD_to_NDC_format(shape) | ||
tensor = tensor.transpose(*shape) | ||
return tensor |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters