NewLang Project
Yet another programm language
Loading...
Searching...
No Matches
object.cpp File Reference
#include "warning_push.h"
#include <torch/torch.h>
#include <ATen/ATen.h>
#include "warning_pop.h"
#include <codecvt>
#include "object.h"
#include "context.h"
#include "runtime.h"
Include dependency graph for object.cpp:

Go to the source code of this file.

Functions

std::string TensorToString (const torch::Tensor &tensor)
 
ObjType fromTorchType (at::ScalarType t)
 
ObjType getSummaryTensorType (Obj *obj, ObjType start=ObjType::None)
 
void ConvertStringToTensor (const std::string &from, torch::Tensor &to, ObjType type=ObjType::None)
 
void ConvertStringToTensor (const std::wstring &from, torch::Tensor &to, ObjType type=ObjType::None)
 
void ConvertTensorToString (const torch::Tensor &from, std::string &to, std::vector< Index > *index=nullptr)
 
void ConvertTensorToString (const torch::Tensor &from, std::wstring &to, std::vector< Index > *index=nullptr)
 
void ConvertTensorToDict (const torch::Tensor &from, Obj &to, std::vector< Index > *index=nullptr)
 
ObjType GetTensorType (torch::Tensor &val)
 
at::indexing::Slice toSlice (Obj &obj)
 
Index toIndex (Obj &obj)
 
ObjPtr CreateTensor (torch::Tensor tensor)
 
torch::ScalarType toTorchType (ObjType t)
 
ObjType fromTorchType (torch::Dtype t)
 
std::string DimToString (const Dimension dim)
 
std::string IndexToString (const std::vector< Index > &index)
 
std::ostream & operator<< (std::ostream &out, newlang::Obj &var)
 
std::ostream & operator<< (std::ostream &out, newlang::ObjPtr var)
 
void TensorToString_ (const torch::Tensor &tensor, c10::IntArrayRef shape, std::vector< Index > &ind, const int64_t pos, std::stringstream &str)
 
void ShapeFromDict (const Obj *obj, std::vector< int64_t > &shape)
 
template<typename T >
void ConvertTensorToStringTemplate (const torch::Tensor &from, T &to, std::vector< Index > *index)
 

Variables

static const ObjPtr zero = Obj::CreateValue(0)
 

Function Documentation

◆ TensorToString()

std::string TensorToString ( const torch::Tensor & tensor)

◆ fromTorchType() [1/2]

ObjType fromTorchType ( at::ScalarType t)

◆ getSummaryTensorType()

◆ ConvertStringToTensor() [1/2]

void ConvertStringToTensor ( const std::string & from,
torch::Tensor & to,
ObjType type = ObjType::None )

Definition at line 2151 of file object.cpp.

References LOG_RUNTIME, and toTorchType().

Referenced by newlang::Obj::toType_().

◆ ConvertStringToTensor() [2/2]

void ConvertStringToTensor ( const std::wstring & from,
torch::Tensor & to,
ObjType type = ObjType::None )

Definition at line 2158 of file object.cpp.

References LOG_RUNTIME, and toTorchType().

◆ ConvertTensorToString() [1/2]

void ConvertTensorToString ( const torch::Tensor & from,
std::string & to,
std::vector< Index > * index = nullptr )

Definition at line 2211 of file object.cpp.

References ConvertTensorToStringTemplate().

Referenced by ConvertTensorToStringTemplate(), and newlang::Obj::toType_().

◆ ConvertTensorToString() [2/2]

void ConvertTensorToString ( const torch::Tensor & from,
std::wstring & to,
std::vector< Index > * index = nullptr )

Definition at line 2215 of file object.cpp.

References ConvertTensorToStringTemplate().

◆ ConvertTensorToDict()

void ConvertTensorToDict ( const torch::Tensor & from,
Obj & to,
std::vector< Index > * index = nullptr )

◆ GetTensorType()

◆ toSlice()

at::indexing::Slice toSlice ( Obj & obj)

◆ toIndex()

◆ CreateTensor()

◆ toTorchType()

◆ fromTorchType() [2/2]

ObjType fromTorchType ( torch::Dtype t)

Definition at line 112 of file object.cpp.

References LOG_RUNTIME.

◆ DimToString()

std::string DimToString ( const Dimension dim)

Definition at line 145 of file object.cpp.

◆ IndexToString()

std::string IndexToString ( const std::vector< Index > & index)

Definition at line 152 of file object.cpp.

Referenced by newlang::Obj::index_get(), and newlang::Obj::index_set_().

◆ operator<<() [1/2]

std::ostream & operator<< ( std::ostream & out,
newlang::Obj & var )

Definition at line 164 of file object.cpp.

References newlang::Obj::toString().

◆ operator<<() [2/2]

std::ostream & operator<< ( std::ostream & out,
newlang::ObjPtr var )

Definition at line 169 of file object.cpp.

◆ TensorToString_()

void TensorToString_ ( const torch::Tensor & tensor,
c10::IntArrayRef shape,
std::vector< Index > & ind,
const int64_t pos,
std::stringstream & str )

Definition at line 1332 of file object.cpp.

References ASSERT, and TensorToString_().

Referenced by TensorToString(), and TensorToString_().

◆ ShapeFromDict()

void ShapeFromDict ( const Obj * obj,
std::vector< int64_t > & shape )

◆ ConvertTensorToStringTemplate()

template<typename T >
void ConvertTensorToStringTemplate ( const torch::Tensor & from,
T & to,
std::vector< Index > * index )

Definition at line 2171 of file object.cpp.

References ASSERT, ConvertTensorToString(), and LOG_RUNTIME.

Referenced by ConvertTensorToString(), and ConvertTensorToString().

Variable Documentation

◆ zero

const ObjPtr zero = Obj::CreateValue(0)
static

Definition at line 3040 of file object.cpp.

Referenced by newlang::Obj::IteratorData().