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")
| 27 | |
| 28 | |
| 29 | def 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 | |
| 43 | def to_vocab_buffer(vocab_dict, name): |