MCPcopy
hub / github.com/PaddlePaddle/PaddleNLP / to_tensor

Function to_tensor

paddlenlp/experimental/faster_tokenizer.py:29–40  ·  view source on GitHub ↗

Create the tensor that the value holds the list of string. NOTICE: The value will be holded in the cpu place. Args: string_values(list[string]): The value will be setted to the tensor. name(string): The name of the tensor.

(string_values, name="text")

Source from the content-addressed store, hash-verified

27
28
29def to_tensor(string_values, name="text"):
30 """
31 Create the tensor that the value holds the list of string.
32 NOTICE: The value will be holded in the cpu place.
33
34 Args:
35 string_values(list[string]): The value will be setted to the tensor.
36 name(string): The name of the tensor.
37 """
38 tensor = paddle.Tensor(core.VarDesc.VarType.STRING, [], name, core.VarDesc.VarType.STRINGS, False)
39 tensor.value().set_string_list(string_values)
40 return tensor
41
42
43def to_vocab_buffer(vocab_dict, name):

Callers 3

perf.pyFile · 0.90
forwardMethod · 0.85
predictMethod · 0.85

Calls 1

valueMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…