-
Notifications
You must be signed in to change notification settings - Fork 338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added TimestampRulesFilter implementation #45
Changes from all commits
68d50b6
7208dbb
6aae04f
ee95bb0
4579af5
5534094
7f1f2d0
8630d3c
ecc88db
9ce87d6
892a64a
662507a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -30,6 +30,15 @@ extension MLMultiArray { | |||||
return linearOffset | ||||||
} | ||||||
|
||||||
func fillLastDimension(indexes: Range<Int>, with value: FloatType) { | ||||||
precondition(shape.count == 3 && shape[0] == 1 && shape[1] == 1, "Must have [1, 1, n] shape") | ||||||
withUnsafeMutableBufferPointer(ofType: FloatType.self) { ptr, strides in | ||||||
for index in indexes { | ||||||
ptr[index * strides[2]] = value | ||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
func fill<Value>(indexes: [[NSNumber]], with value: Value) { | ||||||
let pointer = UnsafeMutablePointer<Value>(OpaquePointer(dataPointer)) | ||||||
let strideInts = strides.map { $0.intValue } | ||||||
|
@@ -135,6 +144,10 @@ func tokenizerNameForVariant(_ variant: ModelVariant) -> String { | |||||
return tokenizerName | ||||||
} | ||||||
|
||||||
func isModelMultilingual(logitsDim: Int?) -> Bool { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have this already here:
Thoughts on combining them? I think checking the logitDims is more robust, perhaps it can be set on the model or the textdecoder on load here:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fair enough, I can tackle it in a separate PR |
||||||
logitsDim != 51864 | ||||||
} | ||||||
|
||||||
func detectVariant(logitsDim: Int, encoderDim: Int) -> ModelVariant { | ||||||
// Defaults | ||||||
var modelVariant: ModelVariant = .base | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This interface is complex in the same way the SegmentSeeker is, I believe most of these are in the tokenizer object but that would require passing this in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right, it's complex. I didn't want to make it dependent on
Tokenizer
so it's decoupled and relatively easier to test. I can change it if you think otherwiseThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, your logic makes sense, we may want a simple object like
SpecialTokens
in the future, and extend tokenizer with it, rather than just adding these index properties themselves as extensions.