File tree Expand file tree Collapse file tree 9 files changed +41
-11
lines changed Expand file tree Collapse file tree 9 files changed +41
-11
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,16 @@ runtime.python_library(
7979 ],
8080)
8181
82+ runtime.python_library(
83+ name = "tensor_layout",
84+ srcs = [
85+ "tensor_layout.py",
86+ ],
87+ deps = [
88+ ":scalar_type",
89+ ]
90+ )
91+
8292runtime.python_library(
8393 name = "memory",
8494 srcs = [
Original file line number Diff line number Diff line change @@ -65,5 +65,6 @@ runtime.python_library(
6565 deps = [
6666 "//executorch/exir:schema",
6767 "//executorch/exir:tensor",
68+ "//executorch/exir:tensor_layout",
6869 ],
6970)
Original file line number Diff line number Diff line change 1616 DataEntry ,
1717 DataPayload ,
1818 DataSerializer ,
19- TensorLayout ,
2019)
2120
2221from executorch .exir .capture ._config import ExecutorchBackendConfig
2322from executorch .exir .emit import EmitterOutput
2423from executorch .exir .schema import Tensor , TensorDataLocation
24+ from executorch .exir .tensor_layout import TensorLayout
2525
2626
2727def serialize_for_executorch (
Original file line number Diff line number Diff line change 33from typing import Dict , Optional , Sequence
44
55from executorch .exir ._serialize ._cord import Cord
6- from executorch .extension . flat_tensor . serialize . flat_tensor_schema import TensorLayout
6+ from executorch .exir . tensor_layout import TensorLayout
77
88
99@dataclass
Original file line number Diff line number Diff line change 1+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2+ # All rights reserved.
3+ #
4+ # This source code is licensed under the BSD-style license found in the
5+ # LICENSE file in the root directory of this source tree.
6+
7+ # pyre-unsafe
8+
9+ from dataclasses import dataclass
10+ from typing import List
11+
12+ from executorch .exir .scalar_type import ScalarType
13+
14+
15+ # Note: keep this in sync with the TensorLayout definition in
16+ # executorch/extension/flat_tensor/serialize/flat_tensor.fbs
17+ @dataclass
18+ class TensorLayout :
19+ scalar_type : ScalarType
20+ sizes : List [int ]
21+ dim_order : List [int ]
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ runtime.python_library(
1313 visibility = [
1414 "//executorch/...",
1515 ],
16+ deps = [
17+ "//executorch/exir:tensor_layout",
18+ ]
1619)
1720
1821runtime.python_library(
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ namespace flat_tensor_flatbuffer;
77file_identifier "FT01";
88file_extension "ptd";
99
10+ // Note: keep this in sync with the python definition in
11+ // executorch/exir/tensor_layout.py
1012table TensorLayout {
1113 scalar_type: executorch_flatbuffer.ScalarType;
1214
Original file line number Diff line number Diff line change 99from dataclasses import dataclass
1010from typing import List , Optional
1111
12- from executorch .exir .scalar_type import ScalarType
12+ from executorch .exir .tensor_layout import TensorLayout
1313
1414# Note: check executorch/extension/data_format/flat_tensor.fbs for explanations of these fields.
1515
1616
17- @dataclass
18- class TensorLayout :
19- scalar_type : ScalarType
20- sizes : List [int ]
21- dim_order : List [int ]
22-
23-
2417@dataclass
2518class DataSegment :
2619 offset : int
Original file line number Diff line number Diff line change 2222from executorch .exir ._serialize .padding import aligned_size
2323
2424from executorch .exir .schema import ScalarType
25- from executorch .extension . flat_tensor . serialize . flat_tensor_schema import TensorLayout
25+ from executorch .exir . tensor_layout import TensorLayout
2626
2727from executorch .extension .flat_tensor .serialize .serialize import (
2828 _deserialize_to_flat_tensor ,
You can’t perform that action at this time.
0 commit comments