| 436 | } |
| 437 | |
| 438 | std::shared_ptr<Tensor> TensorFromJSON(const std::shared_ptr<DataType>& type, |
| 439 | std::string_view data, std::string_view shape, |
| 440 | std::string_view strides, |
| 441 | std::string_view dim_names) { |
| 442 | std::shared_ptr<Array> array = arrow::ArrayFromJSON(type, data); |
| 443 | |
| 444 | simdjson::dom::parser parser; |
| 445 | |
| 446 | auto json_shape = |
| 447 | internal::ResolveSimdjsonResult(parser.parse(shape), "Failed to parse shape") |
| 448 | .ValueOrDie(); |
| 449 | auto shape_vector = internal::GetJsonIntArray(json_shape, "shape").ValueOrDie(); |
| 450 | |
| 451 | auto json_strides = |
| 452 | internal::ResolveSimdjsonResult(parser.parse(strides), "Failed to parse strides") |
| 453 | .ValueOrDie(); |
| 454 | auto strides_vector = internal::GetJsonIntArray(json_strides, "strides").ValueOrDie(); |
| 455 | |
| 456 | auto json_dim_names = internal::ResolveSimdjsonResult(parser.parse(dim_names), |
| 457 | "Failed to parse dimension names") |
| 458 | .ValueOrDie(); |
| 459 | auto dim_names_vector = |
| 460 | internal::GetJsonStringArray(json_dim_names, "dimension names").ValueOrDie(); |
| 461 | |
| 462 | return *Tensor::Make(type, array->data()->buffers[1], shape_vector, strides_vector, |
| 463 | dim_names_vector); |
| 464 | } |
| 465 | |
| 466 | std::shared_ptr<Tensor> TensorFromJSON(const std::shared_ptr<DataType>& type, |
| 467 | std::string_view data, |
no test coverage detected