MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / reallocateOutput

Method reallocateOutput

python/src/infer/pyCore.cpp:470–505  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

468{
469public:
470 void* reallocateOutput(
471 char const* tensorName, void* currentMemory, uint64_t size, uint64_t alignment) noexcept override
472 {
473 try
474 {
475 py::gil_scoped_acquire gil{};
476 py::function pyFunc = utils::getOverride(static_cast<IOutputAllocator*>(this), "reallocate_output");
477
478 if (!pyFunc)
479 {
480 return nullptr;
481 }
482
483 py::object ptr = pyFunc(tensorName, reinterpret_cast<size_t>(currentMemory), size, alignment);
484 try
485 {
486 return reinterpret_cast<void*>(ptr.cast<size_t>());
487 }
488 catch (const py::cast_error& e)
489 {
490 std::cerr << "[ERROR] Return value of reallocateOutput() could not be interpreted as an int"
491 << std::endl;
492 }
493 }
494 catch (std::exception const& e)
495 {
496 std::cerr << "[ERROR] Exception caught in reallocateOutput(): " << e.what() << std::endl;
497 }
498 catch (...)
499 {
500 std::cerr << "[ERROR] Exception caught in reallocateOutput()" << std::endl;
501 return nullptr;
502 }
503
504 return nullptr;
505 }
506
507 void notifyShape(char const* tensorName, Dims const& dims) noexcept override
508 {

Callers

nothing calls this directly

Calls 1

getOverrideFunction · 0.85

Tested by

no test coverage detected