| 431 | |
| 432 | private: |
| 433 | void extractObject(void *object, std::vector<double> &d) { |
| 434 | if (type == typeid(uint8_t)) { |
| 435 | uint8_t *obj = (uint8_t *)object; |
| 436 | for (size_t i = 0; i < dimension; i++) { |
| 437 | d.push_back(obj[i]); |
| 438 | } |
| 439 | } else if (type == typeid(float)) { |
| 440 | float *obj = (float *)object; |
| 441 | for (size_t i = 0; i < dimension; i++) { |
| 442 | d.push_back(obj[i]); |
| 443 | } |
| 444 | #ifdef NGT_HALF_FLOAT |
| 445 | } else if (type == typeid(float16)) { |
| 446 | float16 *obj = (float16 *)object; |
| 447 | for (size_t i = 0; i < dimension; i++) { |
| 448 | d.push_back(obj[i]); |
| 449 | } |
| 450 | #endif |
| 451 | } else { |
| 452 | std::cerr << "ObjectSpace::allocate: Fatal error: unsupported type!" << std::endl; |
| 453 | abort(); |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | public: |
| 458 | void extractObject(Object *o, std::vector<double> &d) { |