Attributes for a single allocation call. Different calls to the same allocator could potentially have different allocation attributes.
| 35 | // Attributes for a single allocation call. Different calls to the same |
| 36 | // allocator could potentially have different allocation attributes. |
| 37 | struct AllocationAttributes { |
| 38 | AllocationAttributes() = default; |
| 39 | |
| 40 | AllocationAttributes(bool no_retry_on_failure, bool allocation_will_be_logged, |
| 41 | std::function<uint64()>* freed_by_func) |
| 42 | : no_retry_on_failure(no_retry_on_failure), |
| 43 | allocation_will_be_logged(allocation_will_be_logged), |
| 44 | freed_by_func(freed_by_func) {} |
| 45 | |
| 46 | // If the first attempt to allocate the memory fails, the allocation |
| 47 | // should return immediately without retrying. |
| 48 | // An example use case is optional scratch spaces where a failure |
| 49 | // has only performance impact. |
| 50 | bool no_retry_on_failure = false; |
| 51 | // If a Tensor is allocated without the following set to true, then |
| 52 | // it is logged as an unknown allocation. During execution Tensors |
| 53 | // should be allocated through the OpKernelContext which records |
| 54 | // which Op is performing the allocation, and sets this flag to |
| 55 | // true. |
| 56 | bool allocation_will_be_logged = false; |
| 57 | // EXPERIMENTAL: If provided, then evaluates to a timing count such that only |
| 58 | // a memory chunk whose freed_at_count is at this value or earlier may be |
| 59 | // returned. |
| 60 | std::function<uint64()>* freed_by_func = nullptr; // Not owned. |
| 61 | |
| 62 | TF_DISALLOW_COPY_AND_ASSIGN(AllocationAttributes); |
| 63 | }; |
| 64 | |
| 65 | // Runtime statistics collected by an allocator. Exactly the same as |
| 66 | // stream_executor::AllocatorStats, but independently defined to preserve the |
no outgoing calls