Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/models/debugging.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "../generators.h"
#include "debugging.h"
#include <inttypes.h>

namespace Generators {
static constexpr size_t c_value_count = 10; // Dump this many values from the start of a tensor
Expand All @@ -26,7 +27,7 @@ void DumpValues(ONNXTensorElementDataType type, const void* p_values_raw, size_t
case Ort::TypeToTensorType<int64_t>::type: {
auto* p_values = reinterpret_cast<const int64_t*>(p_values_raw);
for (size_t i = 0; i < count; i++) {
printf("%lld ", p_values[i]);
printf("%" PRId64 " ", p_values[i]);
}
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/models/input_ids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void InputIDs<T>::Update(RoamingArray<int32_t> next_tokens_unk) {
}
}

template InputIDs<int32_t>;
template InputIDs<int64_t>;
template struct InputIDs<int32_t>;
template struct InputIDs<int64_t>;

} // namespace Generators
4 changes: 2 additions & 2 deletions src/models/kv_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void KV_Cache_Combined::PickPastState(std::span<const int32_t> beam_indices, int
auto element_count = shape_[0] * past_key_size;

const OrtValue& present = *presents_[index];
auto past = OrtValue::CreateTensor<ScoreType>(*model_.allocator_device_, shape_);
std::unique_ptr<OrtValue> past = OrtValue::CreateTensor<ScoreType>(*model_.allocator_device_, shape_);
auto past_span = std::span<ScoreType>(past->GetTensorMutableData<ScoreType>(), element_count);
auto present_span = std::span<const ScoreType>(present.GetTensorData<ScoreType>(), element_count);

Expand Down Expand Up @@ -179,7 +179,7 @@ void KV_Cache::PickPastState(std::span<const int32_t> beam_indices, int index) {
auto element_count = shape_[0] * block_size_per_beam;

const OrtValue& present_value = *presents_[index];
auto past_value = OrtValue::CreateTensor<ScoreType>(*model_.allocator_device_, shape_);
std::unique_ptr<OrtValue> past_value = OrtValue::CreateTensor<ScoreType>(*model_.allocator_device_, shape_);
auto past_span = std::span<ScoreType>(past_value->GetTensorMutableData<ScoreType>(), element_count);
auto present_span = std::span<const ScoreType>(present_value.GetTensorData<ScoreType>(), element_count);

Expand Down
6 changes: 3 additions & 3 deletions src/models/position_ids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void PositionIDs<T>::Update(int current_length) {
attention_mask_shape_[1] = current_length;

const auto* old_data = attention_mask_->GetTensorData<T>();
auto attention_mask = OrtValue::CreateTensor<T>(*model_.allocator_device_, attention_mask_shape_);
std::unique_ptr<OrtValue> attention_mask = OrtValue::CreateTensor<T>(*model_.allocator_device_, attention_mask_shape_);
auto* data = attention_mask->GetTensorMutableData<T>();

switch (model_.device_type_) {
Expand All @@ -125,7 +125,7 @@ void PositionIDs<T>::Update(int current_length) {
}
}

template PositionIDs<int32_t>;
template PositionIDs<int64_t>;
template struct PositionIDs<int32_t>;
template struct PositionIDs<int64_t>;

} // namespace Generators
1 change: 1 addition & 0 deletions src/ort_genai_c.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include <stdint.h>
#include <cstddef>

#ifdef __cplusplus
extern "C" {
Expand Down