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
4 changes: 2 additions & 2 deletions src/PostProcessors/BertProcessing.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(array $config)
* @param bool $addSpecialTokens Whether to add the special tokens associated with the corresponding model.
* @return PostProcessedOutput
*/
public function postProcess(array $tokens, array $tokenPair = null, bool $addSpecialTokens = true): PostProcessedOutput
public function postProcess(array $tokens, ?array $tokenPair = null, bool $addSpecialTokens = true): PostProcessedOutput
{
if ($addSpecialTokens) {
$tokens = array_merge([$this->cls], $tokens, [$this->sep]);
Expand All @@ -60,4 +60,4 @@ public function postProcess(array $tokens, array $tokenPair = null, bool $addSpe

return new PostProcessedOutput($tokens, $tokenTypeIds);
}
}
}
4 changes: 2 additions & 2 deletions src/PostProcessors/ByteLevelPostProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public function __construct(array $config)
* @param bool $addSpecialTokens Whether to add the special tokens associated with the corresponding model.
* @return PostProcessedOutput
*/
public function postProcess(array $tokens, array $tokenPair = null, bool $addSpecialTokens = true): PostProcessedOutput
public function postProcess(array $tokens, ?array $tokenPair = null, bool $addSpecialTokens = true): PostProcessedOutput
{
if ($tokenPair !== null) {
$tokens = array_merge($tokens, $tokenPair);
}

return new PostProcessedOutput($tokens, array_fill(0, count($tokens), 0));
}
}
}
4 changes: 2 additions & 2 deletions src/PostProcessors/TemplateProcessing.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(array $config)
* @param bool $addSpecialTokens Whether to add the special tokens associated with the corresponding model.
* @return PostProcessedOutput
*/
public function postProcess(array $tokens, array $tokenPair = null, bool $addSpecialTokens = true): PostProcessedOutput
public function postProcess(array $tokens, ?array $tokenPair = null, bool $addSpecialTokens = true): PostProcessedOutput
{
$type = $tokenPair === null ? $this->single : $this->pair;

Expand All @@ -63,4 +63,4 @@ public function postProcess(array $tokens, array $tokenPair = null, bool $addSp

return new PostProcessedOutput($processedTokens, $types);
}
}
}
6 changes: 3 additions & 3 deletions src/PreTrainedTokenizers/WhisperTokenizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ public function decodeASR(
* @throws Exception If there is a bug within the function.
* @private
*/
private function findLongestCommonSequence(array $sequences, array $tokenTimestampSequences = null): array
private function findLongestCommonSequence(array $sequences, ?array $tokenTimestampSequences = null): array
{
$leftSequence = $sequences[0];
$leftLength = count($leftSequence);
Expand Down Expand Up @@ -501,7 +501,7 @@ public function collateWordTimestamps($tokens, $tokenTimestamps, $language): arr
*/
private function combineTokensIntoWords(
array $tokens,
string $language = null
?string $language = null
): array
{
$language = $language ?? 'english';
Expand All @@ -522,7 +522,7 @@ public function decode(
array $tokenIds,
bool $skipSpecialTokens = false,
?bool $cleanUpTokenizationSpaces = null,
bool $decodeWithTimestamps = null,
?bool $decodeWithTimestamps = null,
float $timePrecision = 0.02
): string
{
Expand Down
4 changes: 2 additions & 2 deletions src/Tensor/MatrixOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

class MatrixOperator extends \Rindow\Math\Matrix\MatrixOperator
{
protected function alloc(mixed $array, int $dtype = null, array $shape = null): NDArray
protected function alloc(mixed $array, ?int $dtype = null, ?array $shape = null): NDArray
{
if ($dtype === null) {
//$dtype = $this->resolveDtype($array);
$dtype = $this->defaultFloatType;
}
return new Tensor($array, $dtype, $shape);
}
}
}
8 changes: 4 additions & 4 deletions src/Tensor/Tensor.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ class Tensor implements NDArray, Countable, Serializable, IteratorAggregate
protected bool $portableSerializeMode = false;

public function __construct(
mixed $array = null,
int $dtype = null,
array $shape = null,
int $offset = null,
mixed $array = null,
?int $dtype = null,
?array $shape = null,
?int $offset = null,
) {
if ($array === null && $dtype === null && $shape === null && $offset === null) {
// Empty definition for Unserialize
Expand Down
4 changes: 2 additions & 2 deletions src/Tensor/TensorBuffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TensorBuffer implements LinearBuffer
static protected ?FFI $ffi = null;

/** @var array<int,string> $typeString */
protected static $typeString = [
protected static array $typeString = [
NDArray::bool => 'uint8_t',
NDArray::int8 => 'int8_t',
NDArray::int16 => 'int16_t',
Expand Down Expand Up @@ -114,7 +114,7 @@ protected function assertOffsetIsInt(string $method, mixed $offset): void
}
}

protected function isComplex(int $dtype = null): bool
protected function isComplex(?int $dtype = null): bool
{
$dtype = $dtype ?? $this->dtype;
return $dtype == NDArray::complex64 || $dtype == NDArray::complex128;
Expand Down
Loading