| 295 | } |
| 296 | |
| 297 | void SetWeights(int index, const std::vector<float>& data) { |
| 298 | if (data.empty()) return; |
| 299 | if (index == kOptionalTensor) return; |
| 300 | switch (weight_type_) { |
| 301 | case TensorType_FLOAT32: |
| 302 | PopulateTensor(index, data); |
| 303 | break; |
| 304 | case TensorType_UINT8: |
| 305 | SymmetricQuantizeAndPopulate(index, data); |
| 306 | break; |
| 307 | case TensorType_INT8: |
| 308 | SignedSymmetricQuantizeAndPopulate(index, data); |
| 309 | break; |
| 310 | default: |
| 311 | GTEST_FAIL() << "Type not supported: " << weight_type_; |
| 312 | break; |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | const TensorType weight_type_; |
| 317 | const bool is_layer_norm_; |