| 448 | } // end namespace |
| 449 | |
| 450 | int main(int argc, char** argv) { |
| 451 | if (argc < 2) { |
| 452 | ExitWithMsg( |
| 453 | "Please provide buffer table filename as an argument, " |
| 454 | "or invoke with --help for usage instructions."); |
| 455 | } |
| 456 | std::string arg = argv[1]; |
| 457 | if (arg == "--help") { |
| 458 | std::cout << kUsageString << std::endl; |
| 459 | return 0; |
| 460 | } |
| 461 | |
| 462 | BufferAssignment assignment = ParseBufferAssignment(arg); |
| 463 | Log("Buffer assignment: \n" + BufferAssignmentToString(assignment)); |
| 464 | BufferTable table(assignment); |
| 465 | |
| 466 | // Fill out input parameters. |
| 467 | for (const auto& p : assignment.param_to_alloc_idx) { |
| 468 | int param_idx = p.first; |
| 469 | int allocation_idx = p.second; |
| 470 | TupleShape tuple_shape = assignment.buffers_shape[allocation_idx]; |
| 471 | Check(tuple_shape.elements.size() == 1, |
| 472 | "Parameters can not be tuples, got shape: " + |
| 473 | TupleShapeToString(tuple_shape)); |
| 474 | ArrayShape shape = tuple_shape.elements[0]; |
| 475 | Check(GetNumElements(shape) == |
| 476 | assignment.buffers_size[allocation_idx] / ByteSize(shape.type), |
| 477 | "Unexpected number of elements"); |
| 478 | Fill(table.AsPtr()[allocation_idx], shape); |
| 479 | |
| 480 | if (IsVerbose()) { |
| 481 | std::cout << "Filled parameter buffer for param " << param_idx << ": " |
| 482 | << std::endl; |
| 483 | Display(table.AsPtr()[allocation_idx], shape); |
| 484 | } |
| 485 | } |
| 486 | |
| 487 | Log("Launching module"); |
| 488 | EntryModule(/*result_buffer=*/nullptr, |
| 489 | /*run_opts=*/nullptr, |
| 490 | /*params=*/nullptr, table.AsPtr(), |
| 491 | /*prof_counters=*/nullptr); |
| 492 | |
| 493 | std::cout << "Output:" << std::endl; |
| 494 | Log("Output shape: " + |
| 495 | TupleShapeToString(assignment.buffers_shape[assignment.output_idx])); |
| 496 | Display(table.AsPtr()[assignment.output_idx], |
| 497 | assignment.buffers_shape[assignment.output_idx]); |
| 498 | } |
nothing calls this directly
no test coverage detected