-
Notifications
You must be signed in to change notification settings - Fork 389
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update base for Update on "update llama runner to decode single token"
Right now, we don't print the generated response in the eager runner until all tokens are generated. This is not good experience as we need to wait until all tokens are generated to see the response. This PR updates it to decode each new token immediately after it is generated. Differential Revision: [D65578306](https://our.internmc.facebook.com/intern/diff/D65578306/) [ghstack-poisoned]
- Loading branch information
Showing
67 changed files
with
3,932 additions
and
2,355 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
op_get_item, | ||
op_hardtanh, | ||
op_log, | ||
op_max_pool2d, | ||
op_mm, | ||
op_mul, | ||
op_permute, | ||
|
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,77 @@ | ||
# Copyright 2024 Arm Limited and/or its affiliates. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
# pyre-unsafe | ||
from typing import cast, List | ||
|
||
import serializer.tosa_serializer as ts | ||
import torch | ||
from executorch.backends.arm.operators.node_visitor import ( | ||
NodeVisitor, | ||
register_node_visitor, | ||
) | ||
from executorch.backends.arm.tosa_mapping import TosaArg | ||
from executorch.backends.arm.tosa_utils import get_quant_node_args | ||
|
||
from serializer.tosa_serializer import TosaOp | ||
|
||
|
||
@register_node_visitor | ||
class MaxPool2dVisitor(NodeVisitor): | ||
target = "aten.max_pool2d.default" | ||
|
||
def __init__(self, *args): | ||
super().__init__(*args) | ||
|
||
def define_node( | ||
self, | ||
node: torch.fx.Node, | ||
tosa_graph: ts.TosaSerializer, | ||
inputs: List[TosaArg], | ||
output: TosaArg, | ||
is_quant_node: bool, | ||
) -> None: | ||
|
||
input_tensor = inputs[0] | ||
kernel_size = inputs[1].special | ||
stride = inputs[2].special | ||
|
||
try: | ||
padding = [*inputs[3].special, *inputs[3].special] | ||
except IndexError: | ||
padding = [0, 0, 0, 0] | ||
|
||
accumulator_type = input_tensor.dtype | ||
|
||
if is_quant_node: | ||
# Accumulator type always is int8 when input tensor is an integer type. | ||
accumulator_type = ts.DType.INT8 | ||
|
||
# Initilize zero point to zero. | ||
input_zp = 0 | ||
output_zp = 0 | ||
|
||
if is_quant_node: | ||
input_zp = get_quant_node_args( | ||
cast(torch.fx.Node, node.all_input_nodes[0]) | ||
).zp | ||
output_zp = get_quant_node_args(list(node.users)[0]).zp | ||
|
||
attr = ts.TosaSerializerAttribute() | ||
attr.PoolAttribute( | ||
kernel=kernel_size, | ||
stride=stride, | ||
pad=padding, | ||
input_zp=input_zp, | ||
output_zp=output_zp, | ||
accum_dtype=accumulator_type, | ||
) | ||
|
||
tosa_graph.addOperator( | ||
TosaOp.Op().MAX_POOL2D, | ||
[input_tensor.name], | ||
[output.name], | ||
attr, | ||
) |
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
Oops, something went wrong.