Skip to content

Commit 60f0edf

Browse files
committed
Update on "[xnnpack][lite-int] Handle Constant Data"
Handling constant data for xnnpack delegation. This allows us to handle new modules like such: ``` class Module(torch.nn.Module): def __init__(self): super().__init__() self._constant = torch.ones(4, 4, 4) def forward(self, x): return x + self._constant ``` this is the precursor work to handling convolution, as we need to serialize constant data(weights) Differential Revision: [D41050349](https://our.internmc.facebook.com/intern/diff/D41050349/) [ghstack-poisoned]
1 parent a85ab71 commit 60f0edf

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

torch/csrc/jit/backends/xnnpack/compiler/xnn_compiler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ void XNNCompiler::compileModel(
5151
const auto& constant_buffer = *flatbuffer_graph->constant_buffer();
5252
auto buffer_idx = tensor_value->constant_buffer_idx();
5353
const auto buffer_ptr = buffer_idx == 0
54-
? nullptr
55-
: constant_buffer[buffer_idx]->storage()->data();
54+
? nullptr
55+
: constant_buffer[buffer_idx]->storage()->data();
5656
status = xnn_define_tensor_value(
5757
/*subgraph=*/subgraph_ptr,
5858
/*datatype=*/xnn_datatype_fp32,

torch/csrc/jit/backends/xnnpack/serialization/serializer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ namespace delegate {
1313

1414
using namespace fb_xnnpack; // Specified in the schema
1515

16-
1716
class XNNSerializer {
1817
public:
1918
// Constructors
@@ -26,8 +25,9 @@ class XNNSerializer {
2625
: _builder(bufferSize),
2726
_nodes(),
2827
_values(),
29-
_constantBuffer(
30-
{CreateBuffer(_builder, {})}), // index 0 is reserved for non-const data
28+
_constantBuffer({CreateBuffer(
29+
_builder,
30+
{})}), // index 0 is reserved for non-const data
3131
_bufferSizes({0}) {}
3232

3333
// Serializing Nodes

0 commit comments

Comments
 (0)