Skip to content
Snippets Groups Projects
Commit 5de6f355 authored by Yaman Umuroglu's avatar Yaman Umuroglu
Browse files

[Transform] add quantization annotation for TopK indices

parent efc1b85c
No related branches found
No related tags found
No related merge requests found
...@@ -32,6 +32,7 @@ from onnx import TensorProto ...@@ -32,6 +32,7 @@ from onnx import TensorProto
from onnx import helper as oh from onnx import helper as oh
from finn.transformation import Transformation from finn.transformation import Transformation
from finn.core.datatype import DataType
class InsertTopK(Transformation): class InsertTopK(Transformation):
...@@ -87,4 +88,9 @@ class InsertTopK(Transformation): ...@@ -87,4 +88,9 @@ class InsertTopK(Transformation):
# replace the existing output definition with topk indices # replace the existing output definition with topk indices
model.graph.output.insert(0, topk_indices) model.graph.output.insert(0, topk_indices)
model.graph.output.pop(1) model.graph.output.pop(1)
# set quantization annotation for indices
# minimal output dtype for TopK indices dependens on num. classes
# assuming UINT32 is large enough for now (FINN has currently no
# DataType.INT64)
model.set_tensor_datatype(topk_indices.name, DataType.UINT32)
return (model, True) return (model, True)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment