Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
caisar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
caisar
Commits
ad9802e7
Commit
ad9802e7
authored
1 year ago
by
Michele Alberti
Browse files
Options
Downloads
Patches
Plain Diff
[interpretation] Rename utility functions for building CRE values.
parent
a88e69dd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/interpretation.ml
+17
-17
17 additions, 17 deletions
src/interpretation.ml
with
17 additions
and
17 deletions
src/interpretation.ml
+
17
−
17
View file @
ad9802e7
...
@@ -114,8 +114,8 @@ let const_real_of_float value =
...
@@ -114,8 +114,8 @@ let const_real_of_float value =
in
in
Constant
.
ConstReal
(
Number
.
real_literal
~
radix
:
10
~
neg
~
int
~
frac
~
exp
:
None
)
Constant
.
ConstReal
(
Number
.
real_literal
~
radix
:
10
~
neg
~
int
~
frac
~
exp
:
None
)
let
term
t
=
CRE
.
Value
(
Term
t
)
let
value_
term
t
=
CRE
.
Value
(
Term
t
)
let
int
i
=
CRE
.
Value
(
Int
i
)
let
value_
int
i
=
CRE
.
Value
(
Int
i
)
let
builtin_caisar
:
caisar_env
CRE
.
built_in_theories
list
=
let
builtin_caisar
:
caisar_env
CRE
.
built_in_theories
list
=
let
error_message
ls
=
let
error_message
ls
=
...
@@ -147,13 +147,13 @@ let builtin_caisar : caisar_env CRE.built_in_theories list =
...
@@ -147,13 +147,13 @@ let builtin_caisar : caisar_env CRE.built_in_theories list =
(
term_of_caisar_op
engine
(
Data
(
D_csv
features
))
ty_features
,
(
term_of_caisar_op
engine
(
Data
(
D_csv
features
))
ty_features
,
Term
.
t_int_const
(
BigInt
.
of_int
(
Int
.
of_string
label
))
)
Term
.
t_int_const
(
BigInt
.
of_int
(
Int
.
of_string
label
))
)
in
in
term
(
Term
.
t_tuple
[
t_features
;
t_label
])
value_
term
(
Term
.
t_tuple
[
t_features
;
t_label
])
|
Vector
v
->
|
Vector
v
->
let
n
=
Option
.
value_exn
(
Language
.
lookup_vector
v
)
in
let
n
=
Option
.
value_exn
(
Language
.
lookup_vector
v
)
in
assert
(
List
.
length
tl1
=
n
&&
i
<=
n
);
assert
(
List
.
length
tl1
=
n
&&
i
<=
n
);
term
(
List
.
nth_exn
tl1
i
)
value_
term
(
List
.
nth_exn
tl1
i
)
|
Data
_
|
NeuralNetwork
_
->
assert
false
)
|
Data
_
|
NeuralNetwork
_
->
assert
false
)
|
[
Term
t1
;
Term
t2
]
->
term
(
Term
.
t_app_infer
ls
[
t1
;
t2
])
|
[
Term
t1
;
Term
t2
]
->
value_
term
(
Term
.
t_app_infer
ls
[
t1
;
t2
])
|
_
->
invalid_arg
(
error_message
ls
)
|
_
->
invalid_arg
(
error_message
ls
)
in
in
let
length
:
_
CRE
.
builtin
=
let
length
:
_
CRE
.
builtin
=
...
@@ -161,19 +161,19 @@ let builtin_caisar : caisar_env CRE.built_in_theories list =
...
@@ -161,19 +161,19 @@ let builtin_caisar : caisar_env CRE.built_in_theories list =
match
vl
with
match
vl
with
|
[
Term
{
t_node
=
Tapp
(
ls
,
[]
);
_
}
]
->
(
|
[
Term
{
t_node
=
Tapp
(
ls
,
[]
);
_
}
]
->
(
match
caisar_op_of_ls
engine
ls
with
match
caisar_op_of_ls
engine
ls
with
|
Dataset
(
DS_csv
csv
)
->
int
(
BigInt
.
of_int
(
Csv
.
lines
csv
))
|
Dataset
(
DS_csv
csv
)
->
value_
int
(
BigInt
.
of_int
(
Csv
.
lines
csv
))
|
Vector
v
->
|
Vector
v
->
int
(
BigInt
.
of_int
(
Option
.
value_exn
(
Language
.
lookup_vector
v
)))
value_
int
(
BigInt
.
of_int
(
Option
.
value_exn
(
Language
.
lookup_vector
v
)))
|
Data
(
D_csv
data
)
->
int
(
BigInt
.
of_int
(
List
.
length
data
))
|
Data
(
D_csv
data
)
->
value_
int
(
BigInt
.
of_int
(
List
.
length
data
))
|
NeuralNetwork
_
->
assert
false
)
|
NeuralNetwork
_
->
assert
false
)
|
[
Term
{
t_node
=
Tapp
(
ls
,
tl
);
_
}
]
->
(
|
[
Term
{
t_node
=
Tapp
(
ls
,
tl
);
_
}
]
->
(
match
caisar_op_of_ls
engine
ls
with
match
caisar_op_of_ls
engine
ls
with
|
Vector
v
->
|
Vector
v
->
let
n
=
Option
.
value_exn
(
Language
.
lookup_vector
v
)
in
let
n
=
Option
.
value_exn
(
Language
.
lookup_vector
v
)
in
assert
(
List
.
length
tl
=
n
);
assert
(
List
.
length
tl
=
n
);
int
(
BigInt
.
of_int
n
)
value_
int
(
BigInt
.
of_int
n
)
|
Dataset
_
|
Data
_
|
NeuralNetwork
_
->
assert
false
)
|
Dataset
_
|
Data
_
|
NeuralNetwork
_
->
assert
false
)
|
[
Term
t
]
->
term
(
Term
.
t_app_infer
ls
[
t
])
|
[
Term
t
]
->
value_
term
(
Term
.
t_app_infer
ls
[
t
])
|
_
->
invalid_arg
(
error_message
ls
)
|
_
->
invalid_arg
(
error_message
ls
)
in
in
let
vminus
:
_
CRE
.
builtin
=
let
vminus
:
_
CRE
.
builtin
=
...
@@ -208,9 +208,9 @@ let builtin_caisar : caisar_env CRE.built_in_theories list =
...
@@ -208,9 +208,9 @@ let builtin_caisar : caisar_env CRE.built_in_theories list =
(
Term
.
t_app_infer
minus
[
tl
;
c
]
,
ty_cst
))
(
Term
.
t_app_infer
minus
[
tl
;
c
]
,
ty_cst
))
in
in
let
caisar_op
=
Vector
(
Language
.
create_vector
env
n
)
in
let
caisar_op
=
Vector
(
Language
.
create_vector
env
n
)
in
term
(
term_of_caisar_op
~
args
engine
caisar_op
ty
)
value_
term
(
term_of_caisar_op
~
args
engine
caisar_op
ty
)
|
_
->
assert
false
)
|
_
->
assert
false
)
|
[
Term
t1
;
Term
t2
]
->
term
(
Term
.
t_app_infer
ls
[
t1
;
t2
])
|
[
Term
t1
;
Term
t2
]
->
value_
term
(
Term
.
t_app_infer
ls
[
t1
;
t2
])
|
_
->
invalid_arg
(
error_message
ls
)
|
_
->
invalid_arg
(
error_message
ls
)
in
in
let
mapi
:
_
CRE
.
builtin
=
let
mapi
:
_
CRE
.
builtin
=
...
@@ -235,9 +235,9 @@ let builtin_caisar : caisar_env CRE.built_in_theories list =
...
@@ -235,9 +235,9 @@ let builtin_caisar : caisar_env CRE.built_in_theories list =
Vector
(
Language
.
create_vector
env
n
)
Vector
(
Language
.
create_vector
env
n
)
in
in
Eval
(
term_of_caisar_op
~
args
engine
caisar_op
ty
)
Eval
(
term_of_caisar_op
~
args
engine
caisar_op
ty
)
|
Dataset
(
DS_csv
csv
)
->
int
(
BigInt
.
of_int
(
Csv
.
lines
csv
))
|
Dataset
(
DS_csv
csv
)
->
value_
int
(
BigInt
.
of_int
(
Csv
.
lines
csv
))
|
Data
_
|
NeuralNetwork
_
->
assert
false
)
|
Data
_
|
NeuralNetwork
_
->
assert
false
)
|
[
Term
t1
;
Term
t2
]
->
term
(
Term
.
t_app_infer
ls
[
t1
;
t2
])
|
[
Term
t1
;
Term
t2
]
->
value_
term
(
Term
.
t_app_infer
ls
[
t1
;
t2
])
|
_
->
invalid_arg
(
error_message
ls
)
|
_
->
invalid_arg
(
error_message
ls
)
in
in
...
@@ -261,13 +261,13 @@ let builtin_caisar : caisar_env CRE.built_in_theories list =
...
@@ -261,13 +261,13 @@ let builtin_caisar : caisar_env CRE.built_in_theories list =
in
in
NeuralNetwork
nn
NeuralNetwork
nn
in
in
term
(
term_of_caisar_op
engine
caisar_op
ty
)
value_
term
(
term_of_caisar_op
engine
caisar_op
ty
)
|
_
->
invalid_arg
(
error_message
ls
)
|
_
->
invalid_arg
(
error_message
ls
)
in
in
let
apply_neural_network
:
_
CRE
.
builtin
=
let
apply_neural_network
:
_
CRE
.
builtin
=
fun
_engine
ls
vl
_ty
->
fun
_engine
ls
vl
_ty
->
match
vl
with
match
vl
with
|
[
Term
t1
;
Term
t2
]
->
term
(
Term
.
t_app_infer
ls
[
t1
;
t2
])
|
[
Term
t1
;
Term
t2
]
->
value_
term
(
Term
.
t_app_infer
ls
[
t1
;
t2
])
|
_
->
invalid_arg
(
error_message
ls
)
|
_
->
invalid_arg
(
error_message
ls
)
in
in
...
@@ -285,7 +285,7 @@ let builtin_caisar : caisar_env CRE.built_in_theories list =
...
@@ -285,7 +285,7 @@ let builtin_caisar : caisar_env CRE.built_in_theories list =
let
dataset
=
DS_csv
(
Csv
.
load
filename
)
in
let
dataset
=
DS_csv
(
Csv
.
load
filename
)
in
Dataset
dataset
Dataset
dataset
in
in
term
(
term_of_caisar_op
engine
caisar_op
ty
)
value_
term
(
term_of_caisar_op
engine
caisar_op
ty
)
|
_
->
invalid_arg
(
error_message
ls
)
|
_
->
invalid_arg
(
error_message
ls
)
in
in
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment