@@ -126,14 +126,14 @@ int main(int argc, char* argv[]) {
126
126
// Setup inputs and outputs
127
127
// input 9:283:1 6:384:1 152:384:1
128
128
std::string libfm_data = " 9:283:1 6:384:1 152:384:1" ;
129
- std::unordered_map<int32 , std::unordered_map<int32 , float > > instance;
129
+ std::unordered_map<int64 , std::unordered_map<int64 , float > > instance;
130
130
std::vector<std::string> features;
131
131
util::split (libfm_data, ' ' , features);
132
132
for (std::string feature: features) {
133
133
std::vector<std::string> tokens;
134
134
util::split (feature, ' :' , tokens);
135
- int32 fieldid;
136
- int32 featureid;
135
+ int64 fieldid;
136
+ int64 featureid;
137
137
float value;
138
138
int i = 0 ;
139
139
for (std::string token: tokens) {
@@ -147,7 +147,7 @@ int main(int argc, char* argv[]) {
147
147
i++;
148
148
}
149
149
if (instance.find (fieldid) == instance.end ()) {
150
- std::unordered_map<int32 , float > f;
150
+ std::unordered_map<int64 , float > f;
151
151
f[featureid] = value;
152
152
instance[fieldid] = f;
153
153
} else {
@@ -159,13 +159,13 @@ int main(int argc, char* argv[]) {
159
159
std::vector<std::pair<std::string, Tensor> > inputs;
160
160
161
161
for (int i = 0 ; i < sparse_field.size (); i++) {
162
- uint32 fieldid = sparse_field[i];
163
- std::vector<int32 > indice;
164
- std::vector<int32 > fid_list;
162
+ uint64 fieldid = sparse_field[i];
163
+ std::vector<int64 > indice;
164
+ std::vector<int64 > fid_list;
165
165
std::vector<float > fval_list;
166
166
if (instance.find (fieldid) != instance.end ()) {
167
167
int num = 0 ;
168
- for (std::unordered_map<int32 , float >::const_iterator iter = instance[fieldid].begin ();
168
+ for (std::unordered_map<int64 , float >::const_iterator iter = instance[fieldid].begin ();
169
169
iter != instance[fieldid].end (); iter++) {
170
170
indice.push_back (0 );
171
171
indice.push_back (num++);
@@ -179,28 +179,28 @@ int main(int argc, char* argv[]) {
179
179
180
180
// input/sparse_id/index/Placeholder
181
181
auto id_indice_tensor =
182
- test::AsTensor<int32 >(indice, {static_cast <int32 >(indice.size ()/2 ), 2 });
182
+ test::AsTensor<int64 >(indice, {static_cast <int64 >(indice.size ()/2 ), 2 });
183
183
inputs.push_back (std::pair<std::string, Tensor>(" input/sparse_" + std::to_string (fieldid) +" /index/Placeholder" , id_indice_tensor));
184
184
185
185
// input/sparse_id/id/Placeholder
186
- auto id_list_tensor = test::AsTensor<int32 >(fid_list);
186
+ auto id_list_tensor = test::AsTensor<int64 >(fid_list);
187
187
inputs.push_back (std::pair<std::string, Tensor>(" input/sparse_" + std::to_string (fieldid) +" /id/Placeholder" , id_list_tensor));
188
188
189
189
// input/sparse_id/shape/Placeholder not used. Why?
190
- auto id_tensor_shape = TensorShape ({1 , static_cast <int32 >(fid_list.size ())});
190
+ auto id_tensor_shape = TensorShape ({1 , static_cast <int64 >(fid_list.size ())});
191
191
192
192
// input/sparse_id/value/Placeholder
193
193
auto val_list_tensor = test::AsTensor<float >(fval_list);
194
194
inputs.push_back (std::pair<std::string, Tensor>(" input/sparse_" + std::to_string (fieldid) +" /value/Placeholder" , val_list_tensor));
195
195
}
196
196
for (int i = 0 ; i < linear_field.size (); i++) {
197
- uint32 fieldid = linear_field[i];
198
- std::vector<int32 > indice;
199
- std::vector<int32 > fid_list;
197
+ uint64 fieldid = linear_field[i];
198
+ std::vector<int64 > indice;
199
+ std::vector<int64 > fid_list;
200
200
std::vector<float > fval_list;
201
201
if (instance.find (fieldid) != instance.end ()) {
202
202
int num = 0 ;
203
- for (std::unordered_map<int32 , float >::const_iterator iter = instance[fieldid].begin ();
203
+ for (std::unordered_map<int64 , float >::const_iterator iter = instance[fieldid].begin ();
204
204
iter != instance[fieldid].end (); iter++) {
205
205
indice.push_back (0 );
206
206
indice.push_back (num++);
@@ -214,15 +214,15 @@ int main(int argc, char* argv[]) {
214
214
215
215
// input/linear_id/index/Placeholder
216
216
auto id_indice_tensor =
217
- test::AsTensor<int32 >(indice, {static_cast <int32 >(indice.size ()/2 ), 2 });
217
+ test::AsTensor<int64 >(indice, {static_cast <int64 >(indice.size ()/2 ), 2 });
218
218
inputs.push_back (std::pair<std::string, Tensor>(" input/linear_" + std::to_string (fieldid) +" /index/Placeholder" , id_indice_tensor));
219
219
220
220
// input/linear_id/id/Placeholder
221
- auto id_list_tensor = test::AsTensor<int32 >(fid_list);
221
+ auto id_list_tensor = test::AsTensor<int64 >(fid_list);
222
222
inputs.push_back (std::pair<std::string, Tensor>(" input/linear_" + std::to_string (fieldid) +" /id/Placeholder" , id_list_tensor));
223
223
224
224
// input/linear_id/shape/Placeholder not used. Why?
225
- auto id_tensor_shape = TensorShape ({1 , static_cast <int32 >(fid_list.size ())});
225
+ auto id_tensor_shape = TensorShape ({1 , static_cast <int64 >(fid_list.size ())});
226
226
227
227
// input/linear_id/value/Placeholder
228
228
auto val_list_tensor = test::AsTensor<float >(fval_list);
0 commit comments