Skip to content

Commit 0b799e4

Browse files
ai-edge-botcopybara-github
authored andcommitted
Update tensor buffer api for c parity
LiteRT-PiperOrigin-RevId: 826249057
1 parent 30faa6d commit 0b799e4

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

litert/cc/litert_tensor_buffer.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ Expected<TensorBuffer> TensorBuffer::CreateManaged(
6262
return TensorBuffer(tensor_buffer, OwnHandle::kYes);
6363
}
6464

65+
Expected<TensorBuffer> TensorBuffer::CreateManaged(
66+
TensorBufferType buffer_type, const RankedTensorType& tensor_type,
67+
size_t buffer_size) {
68+
return CreateManaged(static_cast<LiteRtTensorBufferType>(buffer_type),
69+
tensor_type, buffer_size);
70+
}
71+
6572
Expected<TensorBuffer> TensorBuffer::CreateFromHostMemory(
6673
const RankedTensorType& tensor_type, void* host_mem_addr,
6774
size_t buffer_size) {

litert/cc/litert_tensor_buffer.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ class TensorBuffer
5757
const Environment& env, TensorBufferType buffer_type,
5858
const RankedTensorType& tensor_type, size_t buffer_size);
5959

60+
// Creates a managed TensorBuffer object in the given buffer type using the
61+
// default environment (if applicable). The returned object is owned by the
62+
// caller.
63+
[[deprecated("Use the overload that takes Environmnet instead.")]]
64+
static Expected<TensorBuffer> CreateManaged(
65+
TensorBufferType buffer_type, const RankedTensorType& tensor_type,
66+
size_t buffer_size);
67+
6068
[[deprecated(
6169
"Use the overload that takes litert::TensorBufferType instead.")]]
6270
static Expected<TensorBuffer> CreateManaged(

0 commit comments

Comments
 (0)