File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change 28
28
#include " caffe2/core/logging.h"
29
29
#include " caffe2/core/net.h"
30
30
#include " caffe2/core/operator.h"
31
+ #include " caffe2/core/tensor_int8.h"
31
32
#include " caffe2/utils/bench_utils.h"
32
33
#include " caffe2/utils/string_utils.h"
33
34
#include " observers/net_observer_reporter_print.h"
@@ -163,12 +164,16 @@ void loadInput(
163
164
CAFFE_THROW (" Not support GPU on mobile." );
164
165
#endif
165
166
} else {
166
- caffe2::TensorCPU* tensor = BlobGetMutableTensor (blob, caffe2::CPU);
167
- CHECK_NOTNULL (tensor);
168
- tensor->Resize (input_dims);
169
167
if (input_type_list[i] == " uint8_t" ) {
170
- tensor->mutable_data <uint8_t >();
168
+ caffe2::int8::Int8TensorCPU* tensor =
169
+ blob->GetMutable <caffe2::int8::Int8TensorCPU>();
170
+ CHECK_NOTNULL (tensor);
171
+ tensor->t .Resize (input_dims);
172
+ tensor->t .mutable_data <uint8_t >();
171
173
} else if (input_type_list[i] == " float" ) {
174
+ caffe2::TensorCPU* tensor = BlobGetMutableTensor (blob, caffe2::CPU);
175
+ CHECK_NOTNULL (tensor);
176
+ tensor->Resize (input_dims);
172
177
tensor->mutable_data <float >();
173
178
} else {
174
179
CAFFE_THROW (" Unsupported input type: " , input_type_list[i]);
Original file line number Diff line number Diff line change 20
20
#include " caffe2/core/init.h"
21
21
#include " caffe2/core/logging.h"
22
22
#include " caffe2/core/operator.h"
23
+ #include " caffe2/core/tensor_int8.h"
23
24
#ifdef CAFFE2_OPTIMIZER
24
25
#include " caffe2/opt/optimizer.h"
25
26
#endif
@@ -137,14 +138,18 @@ int main(int argc, char** argv) {
137
138
if (blob == nullptr ) {
138
139
blob = workspace->CreateBlob (input_names[i]);
139
140
}
140
- caffe2::TensorCPU* tensor = BlobGetMutableTensor (blob, caffe2::CPU);
141
- CHECK_NOTNULL (tensor);
142
- tensor->Resize (input_dims);
143
141
if (input_type_list[i] == " uint8_t" ) {
144
- tensor->mutable_data <uint8_t >();
142
+ caffe2::int8::Int8TensorCPU* tensor =
143
+ blob->GetMutable <caffe2::int8::Int8TensorCPU>();
144
+ CHECK_NOTNULL (tensor);
145
+ tensor->t .Resize (input_dims);
146
+ tensor->t .mutable_data <uint8_t >();
145
147
} else if (input_type_list[i] == " float" ) {
148
+ caffe2::TensorCPU* tensor = BlobGetMutableTensor (blob, caffe2::CPU);
149
+ CHECK_NOTNULL (tensor);
150
+ tensor->Resize (input_dims);
146
151
tensor->mutable_data <float >();
147
- } else {
152
+ } else {
148
153
CAFFE_THROW (" Unsupported input type: " , input_type_list[i]);
149
154
}
150
155
}
You can’t perform that action at this time.
0 commit comments